//============================================================================================
/**
 * @file	p_status.c
 * @brief	ポケモンステータス画面
 * @author	Hiroyuki Nakamura/Akito Mori
 * @date	2004.12.21/ 2008.06.01
 */
//============================================================================================
#include "common.h"
#include "gflib/touchpanel.h"
#include "gflib/strbuf_family.h"
#include "system/procsys.h"
#include "system/arc_tool.h"
#include "system/arc_util.h"
#include "system/clact_tool.h"
#include "system/brightness.h"
#include "system/fontproc.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/numfont.h"
#include "system/softsprite.h"
#include "system/buflen.h"
#include "system/wipe.h"
#include "system/window.h"
#include "battle/battle_common.h"
#include "poketool/monsno.h"
#include "poketool/pokeicon.h"
#include "poketool/pokeparty.h"
#include "poketool/waza_tool.h"
#include "contest/contest.h"
#include "contest/con_tool.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_pokestatus.h"
#include "itemtool/item.h"
#include "application/app_tool.h"
#include "communication/wm_icon.h"
#include "ribbon.h"
#include "system/snd_perap.h"

#include "../../field/sysflag.h"


#define	P_STATUS_H_GLOBAL
#include "application/p_status.h"
#include "pst_sys.h"
#include "pst_obj.h"
#include "pst_bmp.h"
#include "pst_3d.h"
#include "pst_sub.h"
#include "pst_snd_def.h"
#include "application/pst_gra.naix"
#include "application/pst2_gra.naix"

#ifdef PM_DEBUG
//#define DEBUG_LEAF
#ifdef DEBUG_LEAF
static u8 debugleaf=0;
#endif
#endif


//============================================================================================
//	定数定義
//============================================================================================
// メインシーケンス
enum {
	SEQ_IN_SET = 0,
	SEQ_IN,					///< 初期フェード待ち
	SEQ_MAIN,				///< メインコントロール

	SEQ_WAZAIN,				///< 技説明イン待ち
	SEQ_WAZAOUT,			///< 技説明アウト待ち

	SEQ_WAZA_SELECT,		///< 技選択
	SEQ_WAZA_CHANGE,		///< 技入れ替え選択
	SEQ_WAZA_CHANGE_START,	///< 技入れ替え選択開始
	SEQ_WAZA_OBOE,			///< 技覚え/忘れ
	SEQ_WAZA_OBOE_CHECK,	///< 技覚え/忘れ最終確認

	SEQ_RIBBON_IN,			///< リボン説明イン待ち
	SEQ_RIBBON_OUT,			///< リボン説明アウト待ち
	SEQ_RIBBON_SELECT,		///< リボン選択
	SEQ_RIBBON_SCROLL_UP,	///< リボンスクロール（上）
	SEQ_RIBBON_SCROLL_DOWN,	///< リボンスクロール（下）

	SEQ_BUTTON_ANM,			///< 下画面のボタンアニメ待ち

	SEQ_COND_INIT,			///< 初期キー待ち
	SEQ_COND_MSG,			///< メッセージ表示
	SEQ_COND_END,			///< コンディション変更終了

	SEQ_POKE_CHANGE,
	SEQ_POKE_CHANGE_TOUCH,	///< ボックス用：ポケモンタッチ切り替え

	SEQ_OUT_SET,			///< 終了フェードセット
	SEQ_OUT,				///< 終了フェード待ち
};

#define	TMP_MSGBUF_SIZ	( 128 )		///< テンポラリメッセージバッファサイズ

#define	PAGE_PRM_AREA_PX	( 0 )	///< ページのスクリーンPX（クリアに使用）
#define	PAGE_PRM_AREA_PY	( 3 )	///< ページのスクリーンPY
#define	PAGE_PRM_AREA_SX	( 18 )	///< ページのスクリーンSY
#define	PAGE_PRM_AREA_SY	( 20 )	///< ページのスクリーンSY

#define	HP_CHR_PALETTE	( 0xf000 )	///< HPゲージのパレット
#define	HP_CHR_GREEN	( 0x97 )	///< HPゲージのキャラ開始位置（緑）
#define	HP_CHR_YELLOW	( 0xb7 )	///< HPゲージのキャラ開始位置（黄）
#define	HP_CHR_RED		( 0xd7 )	///< HPゲージのキャラ開始位置（赤）
#define	HP_DOT_CHR_MAX	( 6 )		///< HPゲージのキャラ数
#define	HP_DOT_MAX		( 48 )		///< HPゲージのドット数
#define	HP_GAUGE_SCR_PX	( 10 )		///< HPゲージの表示X座標
#define	HP_GAUGE_SCR_PY	( 5 )		///< HPゲージの表示Y座標

#define EXP_CHR_PALETTE 	( 0xe000 )
#define	EXP_CGX				( 55 )	///< EXPゲージキャラ開始位置
#define	EXP_DOT_CHR_MAX		( 7 )	///< EXPゲージキャラ数
#define	EXP_DOT_MAX			( 56 )	///< EXPゲージドット数
#define	EXP_GAUGE_SCR_PX	( 9 )	///< EXPゲージ表示X座標
#define	EXP_GAUGE_SCR_PY	( 19 )	///< EXPゲージ表示Y座標

#define	HEART1_CHR_NUM	( 0x12c )	///< コンテストのハートキャラ開始位置（有）
#define	HEART2_CHR_NUM	( 0x12e )	///< コンテストのハートキャラ開始位置（無）
#define	HEART_MAX		( 6 )		///< コンテストのハートキャラ数
#define	HEART_PX		( 2 )		///< コンテストのハートキャラ表示X座標
#define	HEART_PY		( 32+15 )	///< コンテストのハートキャラ表示Y座標

#define SUB_PAGE_SX		(   0 )		///< サブページのデフォルト位置X
#define SUB_PAGE_SY		(   0 )		///< サブページのデフォルト位置Y
#define SUB_PAGE1_EX	( 128 )		///< わざ説明ページの終了位置X
#define SUB_PAGE1_EY	(   0 )		///< わざ説明ページの終了位置Y
#define SUB_PAGE1_MOVE	(  64 )		///< わざページの移動量
#define SUB_PAGE2_EX	(   0 )		///< リボン説明ページの終了位置X
#define SUB_PAGE2_EY	(  72 )		///< リボン説明ページの終了位置Y
#define SUB_PAGE2_MOVE	(  36 )		///< リボンページの移動量

// ボックス用ポケモン切り替えボタンデータ
#define	BOX_POKECHG_BUTTON_PX	( 24 )
#define	BOX_POKECHG_BUTTON_UPY	( 5 )
#define	BOX_POKECHG_BUTTON_DPY	( 13 )
#define	BOX_POKECHG_BUTTON_SX	( 6 )
#define	BOX_POKECHG_BUTTON_SY	( 3 )

//============================================================================================
//	プロトタイプ宣言
//============================================================================================
static PROC_RESULT PokeStatusProc_Init( PROC * proc, int * seq );
static PROC_RESULT PokeStatusProc_Main( PROC * proc, int * seq );
static PROC_RESULT PokeStatusProc_End( PROC * proc, int * seq );

static int PST_SeqIn( PST_WORK * wk );
static int PST_SeqMain( PST_WORK * wk );
static int PST_SeqWazaIn( PST_WORK * wk );
static int PST_SeqWazaOut( PST_WORK * wk );
static int PST_SeqWazaSelect( PST_WORK * wk );
static int PST_SeqWazaChange( PST_WORK * wk );
static int PST_SeqWazaChangeStart( PST_WORK * wk );
static int PST_SeqWazaAdd( PST_WORK * wk );
static int PST_SeqWazaAddCheck( PST_WORK * wk );
static int PST_SeqRibbonIn( PST_WORK * wk );
static int PST_SeqRibbonOut( PST_WORK * wk );
static int PST_SeqRibbonSelect( PST_WORK * wk );
static int PST_SeqRibbonScrollUp( PST_WORK * wk );
static int PST_SeqRibbonScrollDown( PST_WORK * wk );
static int PST_SeqCondUpInit( PST_WORK * wk );
static int PST_SeqCondUpMsgPut( PST_WORK * wk );
static int PST_SeqCondUpEnd( PST_WORK * wk );
static int PST_SeqPokeChangeTouch( PST_WORK * wk );
static u8 PST_SeqOutSet( PST_WORK * wk );
static u8 PST_SeqOut( PST_WORK * wk );
static int PST_SeqButtonAnm( PST_WORK * wk );
static void PageDirectChange( PST_WORK * wk, s8 page );
static void PokeDirectChange( PST_WORK *wk, const u8 pos);
static int PokePartyCheck( PST_WORK *wk, int pos );
static BOOL PokeSearch_TamagoCheck( PST_WORK * wk );

static void PokeStatusVramBankSet(void);
static void PokeStatusBgSet( GF_BGL_INI * ini );
static void PokeStatusBgExit( GF_BGL_INI * ini );
static void PokeStatusBgGraphicSet( PST_WORK * wk, ARCHANDLE* p_handle, ARCHANDLE* p2_handle );
static void PokeStatusAlphaSet(void);
static void PokeStatusVBlank( void * work );
static void MsgBufCreate( PST_WORK * wk );
static void MsgBufRelease( PST_WORK * wk );
static void PokeStatusSoftSpriteSet( PST_WORK * wk );
static void PokeDataSet( PST_WORK * wk );
static void PokeDataSet_PokePasoParam(PST_WORK * wk,POKEMON_PASO_PARAM * ppp,PST_POKEDATA * dat);
static void PokeDataSet_PokemonParam( PST_WORK * wk, POKEMON_PARAM * pp, PST_POKEDATA * dat );
static void PokeDataSet_PokeParty( PST_WORK * wk );
static void InitPageSet( PST_WORK * wk );
static void PST_PokeVoicePlay( PST_WORK * wk );

static void PageChangeWrite( PST_WORK * wk, u8 next );
static void PageChange( PST_WORK * wk, s8 mv );
static int SubButtonPageChg( PST_WORK * wk );

static void PageBgScreenChg( PST_WORK * wk );
static void HPGaugeSet( PST_WORK * wk );
static void ExpGaugeSet( PST_WORK * wk );

static void PokeChange( PST_WORK * wk, s8 mv );
static s8 PokeSearch( PST_WORK * wk, s8 mv );
static s8 PokeSearch_PokemonParam( PST_WORK * wk, s8 mv );
static s8 PokeSearch_PokeParty( PST_WORK * wk, s8 mv );
static s8 PokeSearch_PokemonPasoParam( PST_WORK * wk, s8 mv );

static u8 WazaInfoScrollIn( PST_WORK * wk );
static u8 WazaInfoScrollOut( PST_WORK * wk );
static u8 WazaCursorMove( PST_WORK * wk, s8 mv );
static void WazaInfoChange( PST_WORK * wk );
static void WazaChangeMain( PST_WORK * wk );
static void WazaInfoPut( PST_WORK * wk );
static void BattleWazaInfoChg( PST_WORK * wk, u32 waza );
static void PST_WazaSetInfoChange( PST_WORK * wk );

static u8 RibbonInfoScrollIn( PST_WORK * wk );
static u8 RibbonInfoScrollOut( PST_WORK * wk );
static void RibbonSelect( PST_WORK * wk, s8 mv );
u8 PokeStatus_RibbonPosIDGet( PST_WORK * wk, u8 cur_pos );

static int PST_PorutoEatCehck( PST_WORK * wk );
static void _set_keytouch_status( PST_WORK *wk, int key_touch );
static int _page_change_check( PST_WORK *wk, int page );

static int NormalWazaPageTouchCheck( PST_WORK * wk );
static int NormalWazaSelectTouchCheck( PST_WORK * wk );
static int ChangeWazaSelectTouchCheck( PST_WORK * wk );
static int WazaSetSelectTouchCheck( PST_WORK * wk );
static int WazaSetCheckTouchCheck( PST_WORK * wk );
static int BoxPokeChangeTouchCheck( PST_WORK * wk );
static int RibbonSelectTouchCkeck( PST_WORK * wk );
static int WazaAddCheckSet( PST_WORK * wk );
static void WazaAddCheckScrnChange( PST_WORK * wk, BOOL flg );
static void WazaChgCheckScrnChange( PST_WORK * wk, BOOL flg );
static void WazaDelScrnChange( PST_WORK * wk );
static int ButtonAnmSet( PST_WORK * wk, u8 frm, u8 px, u8 py, u8 sx, u8 sy, u8 pal1, u8 pal2, u8 next );
static int RetButtonAnmSet( PST_WORK * wk, u8 next );
static int WazaOboeCheckButtonAnmSet( PST_WORK * wk, u8 next );
static int WazaChangeButtonAnmSet( PST_WORK * wk, u8 next );
static int BoxPokeChangeButtonAnmSet( PST_WORK * wk, u8 mv, u8 next );
static int RibbonSelEndButtonAnmSet( PST_WORK * wk, u8 next );

static void BgWinFrameInit( PST_WORK * wk, ARCHANDLE * ah );
static void BgWinFrameExit( PST_WORK * wk );

static void BoxPokeChangeArrowPut( PST_WORK * wk );


//============================================================================================
//	グローバル変数
//============================================================================================
// プロセス定義データ
const PROC_DATA PokeStatusProcData = {
	PokeStatusProc_Init,
	PokeStatusProc_Main,
	PokeStatusProc_End,
	NO_OVERLAY_ID,
};

//#define	BTS_5436_TEST
#ifdef	BTS_5436_TEST
static u32 test_5436_cnt = 0;
#endif	// BTS_5436_TEST


//--------------------------------------------------------------------------------------------
/**
 * コンテストフラグを取得
 *
 * @param	sv		セーブデータ
 *
 * @return	コンテストフラグ
 */
//--------------------------------------------------------------------------------------------
BOOL PokeStatus_ContestFlagGet( SAVEDATA * sv )
{
	return 1;
}

//--------------------------------------------------------------------------------------------
/**
 * ポケスロンパフォーマンス表示用フラグを取得
 *
 * @param	sv		セーブデータ
 *
 * @return	コンテストフラグ
 */
//--------------------------------------------------------------------------------------------
BOOL PokeStatus_PerformanceFlagGet( SAVEDATA * sv )
{
	return SysFlag_StatusPokethlonCheck( SaveData_GetEventWork(sv) );
}


//============================================================================================
//	プロセス関数
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：初期化
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
static PROC_RESULT PokeStatusProc_Init( PROC * proc, int * seq )
{
	PST_WORK * wk;
	ARCHANDLE* p_handle, *p2_handle;

	sys_VBlankFuncChange( NULL, NULL );	// VBlankセット
	sys_HBlankIntrStop();	//HBlank割り込み停止

	GF_Disp_GX_VisibleControlInit();
	GF_Disp_GXS_VisibleControlInit();
	GX_SetVisiblePlane( 0 );
	GXS_SetVisiblePlane( 0 );
	GX_SetVisibleWnd( GX_WNDMASK_NONE );
	GXS_SetVisibleWnd( GX_WNDMASK_NONE );
	G2_BlendNone();
	G2S_BlendNone();

	sys_KeyRepeatSpeedSet( SYS_KEYREPEAT_SPEED_DEF, SYS_KEYREPEAT_WAIT_DEF );
	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_POKESTATUS, 0x45000 );

	p_handle  = ArchiveDataHandleOpen( ARC_PSTATUS_GRA, HEAPID_POKESTATUS );
	p2_handle = ArchiveDataHandleOpen( ARC_POKESTATUS_GRA, HEAPID_POKESTATUS );

	wk = PROC_AllocWork( proc, sizeof(PST_WORK), HEAPID_POKESTATUS );
	memset( wk, 0, sizeof(PST_WORK) );
	wk->dat = PROC_GetParentWork( proc );
	wk->bgl = GF_BGL_BglIniAlloc( HEAPID_POKESTATUS );

	wk->dat->waza_chg = FALSE;	// 初期化

	wk->p3d.poke_anm_sys = PokeAnm_AllocMemory( HEAPID_POKESTATUS, 1, 1 );

	wk->handle = ArchiveDataHandleOpen( ARC_PM_EDIT, HEAPID_POKESTATUS );

	FontProc_LoadBitData( FONT_SYSTEM, HEAPID_POKESTATUS );

	InitTPSystem();						// タッチパネルシステム初期化
	InitTPNoBuff(4);

	PokeStatusVramBankSet();			// VRAM割り当て
	PokeStatusBgSet( wk->bgl );			// BG初期化
	PokeStatusBgGraphicSet( wk, p_handle, p2_handle );		// BGグラフィックセット
	PokeStatusAlphaSet();

	PokeStatus_3DInit( wk );			// 3D初期化

	FontProc_LoadFont( FONT_TOUCH, HEAPID_POKESTATUS );

	MsgBufCreate( wk );					// メッセージ関連作成

	BgWinFrameInit( wk, p2_handle );

	PokeDataSet( wk );					// ポケモンデータ取得

	PokeStatusCellActInit( wk );		// セルアクター初期化
	PokeStatusCellActSet( wk );			// セルアクターセット
	PokeStatus_SoftSpriteSet( wk );		// ソフトウェアスプライトセット
	PokeStatusBallAnmChg( wk );			// 捕獲ボール切り替え
	PokeStatus_StIconChg( wk );			// 状態異常アイコン切り替え

#ifdef DEBUG_LEAF
	{
		POKEMON_PARAM *pp = PokeStatusPokeParamGet(wk);
		u8	buf = 1;

		switch(debugleaf){
		case 0:	PokeParaPut( pp, ID_PARA_leaf0, &buf );	break;
		case 1:	PokeParaPut( pp, ID_PARA_leaf1, &buf );	break;
		case 2:	PokeParaPut( pp, ID_PARA_leaf2, &buf );	break;
		case 3:	PokeParaPut( pp, ID_PARA_leaf3, &buf );	break;
		case 4:	PokeParaPut( pp, ID_PARA_leaf4, &buf );	break;
		case 5:	PokeParaPut( pp, ID_PARA_leaf_crown, &buf );	break;
		}
		debugleaf++;
		debugleaf %=6;
	}

	if(sys.cont & PAD_BUTTON_R){
		wk->dat->pokethlon = 1;
	}else{
		wk->dat->pokethlon = 0;
	}
#endif

	PokeStatus_TemotiPokeIconTrans( wk ); // ポケモンアイコン画像セット

	PokeStatus_DefaultBmpAdd( wk );
	InitPageSet( wk );					// 初期ページ作成

	PokeStatus_CameraInit( wk );		// カメラセット

	sys_VBlankFuncChange( PokeStatusVBlank, wk );	// VBlankセット

	GX_SetDispSelect( GX_DISP_SELECT_MAIN_SUB );

	GF_Disp_DispOn();

	Snd_DataSetByScene( SND_SCENE_SUB_PST, 0, 0 );	// サウンドデータロード(PST)(BGM引継ぎ)

	WirelessIconEasyUnion();

	ArchiveDataHandleClose( p2_handle );
	ArchiveDataHandleClose( p_handle );

#ifdef	BTS_5436_TEST
//	test_5436_cnt = gf_rand() % 64 + 1;
	test_5436_cnt = 1;
#endif	// BTS_5436_TEST

	return PROC_RES_FINISH;
}

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：メイン
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
static PROC_RESULT PokeStatusProc_Main( PROC * proc, int * seq )
{
	PST_WORK * wk  = PROC_GetWork( proc );


#ifdef PM_DEBUG
	if(sys.trg & PAD_BUTTON_L){
		OS_Printf("STATUS remain Memory = %d\n",sys_GetHeapFreeSize( HEAPID_POKESTATUS ));
	}
#endif

	switch( *seq ){
	case SEQ_IN_SET:
		APP_WipeStart( APP_WIPE_IN, HEAPID_POKESTATUS );

		// 隠していたポリゴンを表示する
		SoftSpriteParaSet( wk->p3d.ss, SS_PARA_VANISH, 0 );

		*seq = SEQ_IN;
		break;

	case SEQ_IN:			// 初期フェード待ち
		*seq = PST_SeqIn( wk );
		break;

	case SEQ_MAIN:			// メインコントロール
		*seq = PST_SeqMain( wk );
		break;

	case SEQ_WAZAIN:		// 技説明イン待ち
		*seq = PST_SeqWazaIn( wk );
		break;

	case SEQ_WAZAOUT:		// 技説明アウト待ち
		*seq = PST_SeqWazaOut( wk );
		break;

	case SEQ_WAZA_SELECT:	// 技選択
		*seq = PST_SeqWazaSelect( wk );
		break;

	case SEQ_WAZA_CHANGE_START:	// 技入れ替え選択開始
		*seq = PST_SeqWazaChangeStart( wk );
		break;

	case SEQ_WAZA_CHANGE:	// 技入れ替え選択
		*seq = PST_SeqWazaChange( wk );
		break;

	case SEQ_WAZA_OBOE:		// 技覚え/忘れ
		*seq = PST_SeqWazaAdd( wk );
		break;

	case SEQ_WAZA_OBOE_CHECK:	// 技覚え/忘れ最終確認
		*seq = PST_SeqWazaAddCheck( wk );
		break;

	case SEQ_RIBBON_IN:			// リボン説明イン待ち
		*seq = PST_SeqRibbonIn( wk );
		break;

	case SEQ_RIBBON_OUT:		// リボン説明アウト待ち
		*seq = PST_SeqRibbonOut( wk );
		break;

	case SEQ_RIBBON_SELECT:		// リボン選択
		*seq = PST_SeqRibbonSelect( wk );
		break;

	case SEQ_RIBBON_SCROLL_UP:		// リボンスクロール（上）
		*seq = PST_SeqRibbonScrollUp( wk );
		break;

	case SEQ_RIBBON_SCROLL_DOWN:	// リボンスクロール（下）
		*seq = PST_SeqRibbonScrollDown( wk );
		break;

	case SEQ_BUTTON_ANM:	// 下画面のボタンアニメ待ち
		*seq = PST_SeqButtonAnm( wk );
		break;

	case SEQ_COND_INIT:		// 初期キー待ち
		*seq = PST_SeqCondUpInit( wk );
		break;

	case SEQ_COND_MSG:		// メッセージ表示
		*seq = PST_SeqCondUpMsgPut( wk );
		break;

	case SEQ_COND_END:		// コンディション変更終了
		*seq = PST_SeqCondUpEnd( wk );
		break;

	case SEQ_OUT_SET:		// 終了フェードセット
		*seq = PST_SeqOutSet( wk );
		break;

	case SEQ_OUT:			// 終了フェード待ち
		if( PST_SeqOut( wk ) == TRUE ){
			return PROC_RES_FINISH;
		}
		break;

	case SEQ_POKE_CHANGE:
		// 隠していたポリゴンを表示する
		SoftSpriteParaSet( wk->p3d.ss, SS_PARA_VANISH, 0 );
		*seq = SEQ_MAIN;
		break;

	case SEQ_POKE_CHANGE_TOUCH:
		*seq = PST_SeqPokeChangeTouch( wk );
		break;
	}

	PokeStatus_CellActAnm( wk );
	PokeStatus_RibbonFlashAnm( wk );

	CATS_Draw( wk->crp );

	PokeStatus_3DMain( wk );

	return PROC_RES_CONTINUE;
}

//--------------------------------------------------------------------------------------------
/**
 * プロセス関数：終了
 *
 * @param	proc	プロセスデータ
 * @param	seq		シーケンス
 *
 * @return	処理状況
 */
//--------------------------------------------------------------------------------------------
static PROC_RESULT PokeStatusProc_End( PROC * proc, int * seq )
{
	PST_WORK * wk  = PROC_GetWork( proc );

	sys_VBlankFuncChange( NULL, NULL );	// VBlankセット

	PokeStatus_3DRelease( wk );			// 3D削除
	PokeStatusCellActRerease( wk );		// セルアクター削除
	PokeStatus_BmpFreeAll( wk );
	PokeStatusBgExit( wk->bgl );		// BGL削除
	StopTP();							// タッチパネル終了
	DellVramTransferManager();

	BgWinFrameExit( wk );
	MsgBufRelease( wk );

	FontProc_UnloadFont( FONT_TOUCH );

	ArchiveDataHandleClose( wk->handle );

	FontProc_UnloadBitData( FONT_SYSTEM );

	G2_BlendNone();

	PROC_FreeWork( proc );				// ワーク開放

	sys_DeleteHeap( HEAPID_POKESTATUS );

	return PROC_RES_FINISH;
}


//============================================================================================
//	設定関連
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * VBlank関数
 *
 * @param	work	ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusVBlank( void * work )
{
	PST_WORK * wk = work;

	GF_BGL_VBlankFunc( wk->bgl );
	SoftSpriteTextureTrans( wk->p3d.ssm );

	// セルアクター
	DoVramTransferManager();	// Vram転送マネージャー実行
	CATS_RenderOamTrans();

	OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

//--------------------------------------------------------------------------------------------
/**
 * VRAM設定
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusVramBankSet(void)
{
	GF_BGL_DISPVRAM tbl = {
		GX_VRAM_BG_128_A,				// メイン2DエンジンのBG
		GX_VRAM_BGEXTPLTT_NONE,			// メイン2DエンジンのBG拡張パレット

		GX_VRAM_SUB_BG_128_C,			// サブ2DエンジンのBG
		GX_VRAM_SUB_BGEXTPLTT_NONE,		// サブ2DエンジンのBG拡張パレット

		GX_VRAM_OBJ_64_E,				// メイン2DエンジンのOBJ
		GX_VRAM_OBJEXTPLTT_NONE,		// メイン2DエンジンのOBJ拡張パレット

		GX_VRAM_SUB_OBJ_16_I,			// サブ2DエンジンのOBJ
		GX_VRAM_SUB_OBJEXTPLTT_NONE,	// サブ2DエンジンのOBJ拡張パレット

		GX_VRAM_TEX_0_B,				// テクスチャイメージスロット
		GX_VRAM_TEXPLTT_01_FG			// テクスチャパレットスロット
	};
	GF_Disp_SetBank( &tbl );
}

//--------------------------------------------------------------------------------------------
/**
 * BG設定
 *
 * @param	ini		BGLデータ
 *
 * @return	none
 *
 * @li	Main BG0 = 3D
 * @li	Main BG1 = font
 * @li	Main BG2 = SubBG
 * @li	Main BG3 = BG
 * @li	Sub BG0 = Button
 * @li	Sub BG1 = BG
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusBgSet( GF_BGL_INI * ini )
{
	{	// BG SYSTEM
		GF_BGL_SYS_HEADER BGsys_data = {
			GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BGMODE_0, GX_BG0_AS_3D,
		};
		GF_BGL_InitBG( &BGsys_data );
	}

	// 上画面
	{	// FONT (BMP)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
			0, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME1_M, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, GF_BGL_FRAME1_M );
	}

	{	// SUB PAGE (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x2000, 0, GF_BGL_SCRSIZ_512x512, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xd800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			1, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME2_M, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, GF_BGL_FRAME2_M );
		GF_BGL_ScrollReq( ini, GF_BGL_FRAME2_M, GF_BGL_SCROLL_X_SET, 0 );
		GF_BGL_ScrollReq( ini, GF_BGL_FRAME2_M, GF_BGL_SCROLL_Y_SET, 0 );
	}

	{	// BG (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xd000, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			3, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME3_M, &TextBgCntDat, GF_BGL_MODE_TEXT );
	}

	// 下画面
	{	// 文字表示面
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x10000, GX_BG_EXTPLTT_01,
			0, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME0_S, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, GF_BGL_FRAME0_S );
	}
	{	// 下画面サブ面BG (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x2000, 0, GF_BGL_SCRSIZ_512x512, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xd800, GX_BG_CHARBASE_0x08000, GX_BG_EXTPLTT_01,
			2, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME1_S, &TextBgCntDat, GF_BGL_MODE_TEXT );
		GF_BGL_ScrClear( ini, GF_BGL_FRAME1_S );
	}
	{	// 下画面メインBG (CHAR)
		GF_BGL_BGCNT_HEADER TextBgCntDat = {
			0, 0, 0x800, 0, GF_BGL_SCRSIZ_256x256, GX_BG_COLORMODE_16,
			GX_BG_SCRBASE_0xd000, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01,
			3, 0, 0, FALSE
		};
		GF_BGL_BGControlSet( ini, GF_BGL_FRAME2_S, &TextBgCntDat, GF_BGL_MODE_TEXT );
	}

	GF_BGL_ClearCharSet( GF_BGL_FRAME1_M, 32, 0, HEAPID_POKESTATUS );
	GF_BGL_ClearCharSet( GF_BGL_FRAME0_S, 32, 0, HEAPID_POKESTATUS );
}

//--------------------------------------------------------------------------------------------
/**
 * BG解放
 *
 * @param	ini		BGLデータ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusBgExit( GF_BGL_INI * ini )
{
	GF_Disp_GX_VisibleControlInit();
	GF_Disp_GXS_VisibleControlInit();

	GF_BGL_BGControlExit( ini, GF_BGL_FRAME2_S );
	GF_BGL_BGControlExit( ini, GF_BGL_FRAME1_S );
	GF_BGL_BGControlExit( ini, GF_BGL_FRAME0_S );
	GF_BGL_BGControlExit( ini, GF_BGL_FRAME3_M );
	GF_BGL_BGControlExit( ini, GF_BGL_FRAME2_M );
	GF_BGL_BGControlExit( ini, GF_BGL_FRAME1_M );

	sys_FreeMemory( HEAPID_POKESTATUS, ini );
}

//--------------------------------------------------------------------------------------------
/**
 * グラフィックデータセット
 *
 * @param	wk			ステータス画面ワーク
 * @param   p_handle	ARC_PSTATUS_GRAのハンドル
 * @param   p2_handle	ARC_POKESTATUS_GRAのハンドル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusBgGraphicSet( PST_WORK * wk, ARCHANDLE* p_handle, ARCHANDLE* p2_handle )
{
	//	PLATINUM_MERGE	ハンドル式に変更
	// 上画面
	ArcUtil_HDL_PalSet(    p2_handle, NARC_pst2_gra_p_status_nclr, PALTYPE_MAIN_BG,0,16*0x20,HEAPID_POKESTATUS);
	ArcUtil_HDL_BgCharSet( p2_handle, NARC_pst2_gra_ps_bg_up_ncgr,wk->bgl,GF_BGL_FRAME3_M,0,32*17*8*8/2,0,HEAPID_POKESTATUS);
	ArcUtil_HDL_ScrnSet(   p2_handle, NARC_pst2_gra_ps_tmemo_up_nscr, wk->bgl,GF_BGL_FRAME3_M,0,0,0,HEAPID_POKESTATUS);

	//	PLATINUM_MERGE	ハンドル式に変更
	// 下画面
	ArcUtil_HDL_PalSet( p2_handle,NARC_pst2_gra_p_status_nclr,PALTYPE_SUB_BG,0,16*0x20,HEAPID_POKESTATUS);
	ArcUtil_HDL_BgCharSet( p2_handle, NARC_pst2_gra_ps_bg_dw_ncgr, wk->bgl,GF_BGL_FRAME2_S,0,32*17*8*8/2,0,HEAPID_POKESTATUS);
	// 下画面サブページ初期化
	ArcUtil_HDL_BgCharSet( p2_handle, NARC_pst2_gra_ps_sub_ncgr, wk->bgl,GF_BGL_FRAME1_S,0,0,0,HEAPID_POKESTATUS);
	ArcUtil_HDL_ScrnSet( p2_handle,NARC_pst2_gra_ps_sub_nscr, wk->bgl, GF_BGL_FRAME1_S, 0, 0, 0, HEAPID_POKESTATUS );
}

//--------------------------------------------------------------------------------------------
/**
 * 半透明設定
 *
 * @param	none
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeStatusAlphaSet(void)
{
	G2_SetBlendAlpha(
		GX_BLEND_PLANEMASK_BG0,
		GX_BLEND_PLANEMASK_BG1|GX_BLEND_PLANEMASK_BG2|
		GX_BLEND_PLANEMASK_BG3|GX_BLEND_PLANEMASK_OBJ, 23, 8 );
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連作成
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MsgBufCreate( PST_WORK * wk )
{
	// メッセージマネージャ作成
	wk->msg_man = MSGMAN_Create(
					MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_pokestatus_dat, HEAPID_POKESTATUS );

	wk->rbn_man = MSGMAN_Create(
					MSGMAN_TYPE_DIRECT, ARC_MSG, NARC_msg_ribbon_dat, HEAPID_POKESTATUS );

	// 8x8フォント作成
	wk->num_font = NUMFONT_Create(
					FBMP_COL_BLACK, FBMP_COL_BLK_SDW, FBMP_COL_NULL, HEAPID_POKESTATUS );

	wk->wset = WORDSET_Create( HEAPID_POKESTATUS );

	wk->pp.monsname = STRBUF_Create( BUFLEN_POKEMON_NAME, HEAPID_POKESTATUS );
	wk->pp.nickname = STRBUF_Create( BUFLEN_POKEMON_NAME, HEAPID_POKESTATUS );
	wk->pp.oya = STRBUF_Create( BUFLEN_PERSON_NAME, HEAPID_POKESTATUS );

	wk->msg_buf = STRBUF_Create( TMP_MSGBUF_SIZ, HEAPID_POKESTATUS );

	wk->wman = MSGMAN_Create(
					MSGMAN_TYPE_NORMAL, ARC_MSG, NARC_msg_wazaname_dat, HEAPID_POKESTATUS );

	wk->player_name = STRBUF_Create( PERSON_NAME_SIZE+EOM_SIZE, HEAPID_POKESTATUS );
	if( wk->dat->player_name != NULL ){
		STRBUF_SetStringCode( wk->player_name, wk->dat->player_name );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * メッセージ関連削除
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void MsgBufRelease( PST_WORK * wk )
{
	MSGMAN_Delete( wk->wman );
	MSGMAN_Delete( wk->rbn_man );
	MSGMAN_Delete( wk->msg_man );
	NUMFONT_Delete( wk->num_font );
	WORDSET_Delete( wk->wset );
	STRBUF_Delete( wk->pp.monsname );
	STRBUF_Delete( wk->pp.nickname );
	STRBUF_Delete( wk->pp.oya );
	STRBUF_Delete( wk->msg_buf );
	STRBUF_Delete( wk->player_name );
}

// ＢＧウィンドウフレーム定義
#define	BGWF_WAZA_CHG_SX	( 10 )
#define	BGWF_WAZA_CHG_SY	( 4 )
#define	BGWF_WAZA_DEL_SX	( 17 )
#define	BGWF_WAZA_DEL_SY	( 6 )
#define	BGWF_BOX_POKE_SX	( 11 )
#define	BGWF_BOX_POKE_SY	( 14 )
#define	BGWF_BOX_ARROW_SX	( 6 )
#define	BGWF_BOX_ARROW_SY	( 3 )

//--------------------------------------------------------------------------------------------
/**
 * ＢＧウィンドウフレーム初期化
 *
 * @param	wk		ステータス画面ワーク
 * @param	ah		グラフィックアーカイブハンドル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgWinFrameInit( PST_WORK * wk, ARCHANDLE * ah )
{
	wk->wfrm = BGWINFRM_Create( wk->bgl, BGWINFRM_TRANS_VBLANK, PST_WFRM_MAX, HEAPID_POKESTATUS );

	// 技忘れボタン
	BGWINFRM_Add( wk->wfrm, PST_WFRM_WAZADEL_BUTTON, GF_BGL_FRAME2_S, BGWF_WAZA_DEL_SX, BGWF_WAZA_DEL_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_WAZADEL_BUTTON, ah, NARC_pst2_gra_ps_waza_wasure_NSCR, FALSE );

	// 覚える技
	BGWINFRM_Add( wk->wfrm, PST_WFRM_5TH_WAZA, GF_BGL_FRAME2_S, BGWF_WAZA_DEL_SX, BGWF_WAZA_DEL_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_5TH_WAZA, ah, NARC_pst2_gra_ps_waza_5th_NSCR, FALSE );

	// 技入れ替えボタン
	BGWINFRM_Add( wk->wfrm, PST_WFRM_WAZACHG_BUTTON, GF_BGL_FRAME2_S, BGWF_WAZA_CHG_SX, BGWF_WAZA_CHG_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_WAZACHG_BUTTON, ah, NARC_pst2_gra_ps_waza_irekae_NSCR, FALSE );

	// 技なし
	BGWINFRM_Add( wk->wfrm, PST_WFRM_WAZA_NONE, GF_BGL_FRAME2_S, BGWF_WAZA_CHG_SX, BGWF_WAZA_CHG_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_WAZA_NONE, ah, NARC_pst2_gra_ps_waza_none_NSCR, FALSE );

	// ボックスのポケモンアイコン表示ＢＧ
	BGWINFRM_Add( wk->wfrm, PST_WFRM_BOX_POKE, GF_BGL_FRAME2_S, BGWF_BOX_POKE_SX, BGWF_BOX_POKE_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_BOX_POKE, ah, NARC_pst2_gra_ps_box_dw_NSCR, FALSE );

	// ボックスのポケモンアイコンスクロール上矢印
	BGWINFRM_Add( wk->wfrm, PST_WFRM_BOX_SU, GF_BGL_FRAME2_S, BGWF_BOX_ARROW_SX, BGWF_BOX_ARROW_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_BOX_SU, ah, NARC_pst2_gra_ps_box_su_NSCR, FALSE );

	// ボックスのポケモンアイコンスクロール下矢印
	BGWINFRM_Add( wk->wfrm, PST_WFRM_BOX_SD, GF_BGL_FRAME2_S, BGWF_BOX_ARROW_SX, BGWF_BOX_ARROW_SY );
	BGWINFRM_FrameSetArcHandle(
		wk->wfrm, PST_WFRM_BOX_SD, ah, NARC_pst2_gra_ps_box_sd_NSCR, FALSE );
}

//--------------------------------------------------------------------------------------------
/**
 * ＢＧウィンドウフレーム削除
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BgWinFrameExit( PST_WORK * wk )
{
	BGWINFRM_Exit( wk->wfrm );
}


//============================================================================================
//	メインシーケンス
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：初期フェード待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqIn( PST_WORK * wk )
{
	if( WIPE_SYS_EndCheck() == TRUE ){
		PokeStatus_SoftSpriteAnmSet( wk );
		PST_PokeVoicePlay( wk );

		if( wk->dat->mode == PST_MODE_WAZAADD ){
			return SEQ_WAZA_OBOE;
		}else if( wk->dat->mode == PST_MODE_CONDITION ){
			return SEQ_COND_INIT;
		}else{
			return SEQ_MAIN;
		}
	}
	return SEQ_IN;
}

static int debug_x = 0;
static int debug_y = 0;

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：メインコントロール
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqMain( PST_WORK * wk )
{
#ifdef	BTS_5436_TEST
	test_5436_cnt--;
	if( test_5436_cnt == 0 ){
		sys.trg = PAD_BUTTON_B;
	}
#endif	// BTS_5436_TEST

	// 終了フラグが立っている？
	if( wk->sub_end == 1 ){
		wk->dat->ret_mode = PST_RET_CANCEL;
		return SEQ_OUT_SET;
	}

	// 左ページへ
	if( sys.repeat & PAD_KEY_LEFT ){
		PageChange( wk, -1 );
		return SEQ_MAIN;
	}

	// 右ﾍﾟｰｼﾞへ
	if( sys.repeat & PAD_KEY_RIGHT ){
		PageChange( wk, 1 );
		return SEQ_MAIN;
	}

	// 上のポケモンへ
	if( sys.repeat & PAD_KEY_UP ){
		PokeChange( wk, -1 );
		return SEQ_POKE_CHANGE;
	}

	// 下のポケモンへ
	if( sys.repeat & PAD_KEY_DOWN ){
		PokeChange( wk, 1 );
		return SEQ_POKE_CHANGE;
	}

	// ステータス表示終了
	if( sys.trg & PAD_BUTTON_CANCEL ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		wk->dat->ret_mode = PST_RET_CANCEL;
		_set_keytouch_status( wk, APP_END_KEY );
		return RetButtonAnmSet( wk, SEQ_OUT_SET );
	}

	// ポルトか毛艶の時に決定
	if( sys.trg & PAD_BUTTON_DECIDE ){

		switch(wk->page){
		// 戦闘ワザ文章表示
		case PST_PAGE_PARAM_B_SKILL:
			Snd_SePlay( PST_SE_WAZAINFO );
			wk->cur_pos = 0;
			return SEQ_WAZAIN;
		// リボンコメント表示
		case PST_PAGE_RIBBON:
			if( wk->ribbon_max != 0 ){
				Snd_SePlay( PST_SE_DECIDE );
				wk->ribbon_pos = 0;
				return SEQ_RIBBON_IN;
			}
			break;
		}
	}

	// 技選択タッチチェック
	if( wk->page == PST_PAGE_PARAM_B_SKILL ){
		int	ret = NormalWazaPageTouchCheck( wk );

		if( ret != RECT_HIT_NONE ){
			if( wk->pp.waza[ret] != 0 ){
				Snd_SePlay( PST_SE_WAZAINFO );
				wk->cur_pos = ret;
				return SEQ_WAZAIN;
			}
		}
	}

	// リボンタッチチェック
	if( wk->page == PST_PAGE_RIBBON ){
		int	ret = RibbonSelectTouchCkeck( wk );
		if( ret != RECT_HIT_NONE ){
			if( ret < 9 && ret < wk->ribbon_max ){
				Snd_SePlay( PST_SE_DECIDE );
				wk->ribbon_pos = ret;
				return SEQ_RIBBON_IN;
			}
		}
	}

	// ボックスポケモン切り替えタッチチェック
	if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
		int	ret = BoxPokeChangeTouchCheck( wk );

		if( ret == 0 ){
			if( PokeSearch( wk, -1 ) != -1 ){
				Snd_SePlay( PST_SE_DECIDE );
				return BoxPokeChangeButtonAnmSet( wk, 0, SEQ_POKE_CHANGE_TOUCH );
			}
			return SEQ_MAIN;
		}else if( ret == 1 ){
			if( PokeSearch( wk, 1 ) != -1 ){
				Snd_SePlay( PST_SE_DECIDE );
				return BoxPokeChangeButtonAnmSet( wk, 1, SEQ_POKE_CHANGE_TOUCH );
			}
			return SEQ_MAIN;
		}
	}

	// サブページ変更中の場合
	return SubButtonPageChg( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技説明イン待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaIn( PST_WORK * wk )
{
	if( WazaInfoScrollIn( wk ) == TRUE ){
		WazaChgCheckScrnChange( wk, TRUE );
		return SEQ_WAZA_SELECT;
	}
	return SEQ_WAZAIN;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技説明アウト待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaOut( PST_WORK * wk )
{
	if( WazaInfoScrollOut( wk ) == TRUE ){
		return SEQ_MAIN;
	}
	return SEQ_WAZAOUT;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技選択
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaSelect( PST_WORK * wk )
{
	if( sys.trg & PAD_KEY_UP ){
		if( WazaCursorMove( wk, -1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_SELECT;
	}

	if( sys.trg & PAD_KEY_DOWN ){
		if( WazaCursorMove( wk, 1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_SELECT;
	}

	if( sys.trg & PAD_BUTTON_DECIDE ){
		if( wk->dat->mode != PST_MODE_NO_WAZACHG ){
			Snd_SePlay( PST_SE_DECIDE );
			return WazaChangeButtonAnmSet( wk, SEQ_WAZA_CHANGE_START );
		}
	}

	if( sys.trg & PAD_BUTTON_CANCEL ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		WazaChgCheckScrnChange( wk, FALSE );
		return RetButtonAnmSet( wk, SEQ_WAZAOUT );
	}

	{	// タッチチェック
		int	ret = ChangeWazaSelectTouchCheck( wk );

		if( ret == 4 ){
			if( wk->dat->mode != PST_MODE_NO_WAZACHG ){
				Snd_SePlay( PST_SE_DECIDE );
				return WazaChangeButtonAnmSet( wk, SEQ_WAZA_CHANGE_START );
			}
		}else if( ret == 5 ){
			Snd_SePlay( PST_SE_RET_BUTTON );
			WazaChgCheckScrnChange( wk, FALSE );
			return RetButtonAnmSet( wk, SEQ_WAZAOUT );
		}else if( ret != RECT_HIT_NONE ){
			if( wk->pp.waza[ret] != 0 ){
				wk->cur_pos = ret;
				Snd_SePlay( PST_SE_CURSOR_MOVE );
				WazaInfoChange( wk );
				return SEQ_WAZA_SELECT;
			}
		}
	}

	return SEQ_WAZA_SELECT;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技入れ替え選択開始
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaChangeStart( PST_WORK * wk )
{
	WazaChgCheckScrnChange( wk, FALSE );
	PokeStatus_SubWazaCursorSet( wk );
	wk->sub_cur = wk->cur_pos;
	return SEQ_WAZA_CHANGE;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技入れ替え選択
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaChange( PST_WORK * wk )
{
	if( sys.trg & PAD_KEY_UP ){
		if( WazaCursorMove( wk, -1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_CHANGE;
	}

	if( sys.trg & PAD_KEY_DOWN ){
		if( WazaCursorMove( wk, 1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_CHANGE;
	}

	if( sys.trg & PAD_BUTTON_DECIDE ){
		WazaChgCheckScrnChange( wk, TRUE );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
		if( wk->cur_pos != wk->sub_cur ){
			Snd_SePlay( PST_SE_DECIDE );
			WazaChangeMain( wk );
			PokeStatus_WazaTypePosChange( wk, wk->cur_pos, wk->sub_cur );
			PokeStatus_SkillChgRewrite( wk );
			WazaInfoChange( wk );
		}else{
			Snd_SePlay( PST_SE_CANCEL );
		}
		return SEQ_WAZA_SELECT;
	}

	if( sys.trg & PAD_BUTTON_CANCEL ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		WazaChgCheckScrnChange( wk, TRUE );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
		return RetButtonAnmSet( wk, SEQ_WAZA_SELECT );
	}

	{	// タッチチェック
		int	ret = NormalWazaSelectTouchCheck( wk );

		if( ret == 4 ){
			Snd_SePlay( PST_SE_RET_BUTTON );
			WazaChgCheckScrnChange( wk, TRUE );
			CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
			return RetButtonAnmSet( wk, SEQ_WAZA_SELECT );
		}else if( ret != RECT_HIT_NONE ){
			if( wk->pp.waza[ret] != 0 ){
				WazaChgCheckScrnChange( wk, TRUE );
				CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
/*
	SYSTEM1576	【ステータス画面で技入れ替え時にカーソルの挙動がおかしくなる】
	場所	src/application/p_status.c
*/
#if GS_AFTERMASTER_GF1062_20091009_FIX
				if( ret != wk->sub_cur ){
					wk->cur_pos = ret;
#else
				wk->cur_pos = ret;
				if( wk->cur_pos != wk->sub_cur ){
#endif
					Snd_SePlay( PST_SE_DECIDE );
					WazaChangeMain( wk );
					PokeStatus_WazaTypePosChange( wk, wk->cur_pos, wk->sub_cur );
					PokeStatus_SkillChgRewrite( wk );
					WazaInfoChange( wk );
				}else{
					Snd_SePlay( PST_SE_CANCEL );
				}
				return SEQ_WAZA_SELECT;
			}
		}
	}

	return SEQ_WAZA_CHANGE;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技覚え/忘れ
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaAdd( PST_WORK * wk )
{
	if( sys.trg & PAD_KEY_UP ){
		if( WazaCursorMove( wk, -1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_OBOE;
	}

	if( sys.trg & PAD_KEY_DOWN ){
		if( WazaCursorMove( wk, 1 ) == TRUE ){
			Snd_SePlay( PST_SE_CURSOR_MOVE );
			WazaInfoChange( wk );
		}
		return SEQ_WAZA_OBOE;
	}

	if( sys.trg & PAD_BUTTON_DECIDE ){
		Snd_SePlay( PST_SE_DECIDE );
		if( wk->cur_pos == 4 ){
			wk->dat->ret_sel = 4;
			wk->dat->ret_mode = PST_RET_DECIDE;
			return SEQ_OUT_SET;
		}else{
			if( HidenWazaCheck( wk->pp.waza[wk->cur_pos] ) == TRUE && wk->dat->waza != 0 ){
				CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_KIND], 0 );
				PokeStatus_WazaOboeErrorMsgPut( wk );
				return SEQ_WAZA_OBOE;
			}else{
				return WazaAddCheckSet( wk );
			}
		}
	}

	if( sys.trg & PAD_BUTTON_CANCEL ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		wk->dat->ret_sel  = 4;
		wk->dat->ret_mode = PST_RET_CANCEL;
		return RetButtonAnmSet( wk, SEQ_OUT_SET );
	}

	{	// タッチ
		int	ret = WazaSetSelectTouchCheck( wk );

		switch( ret ){
		case RECT_HIT_NONE:
			break;

		case 4:
			if( wk->dat->waza != 0 ){
				Snd_SePlay( PST_SE_DECIDE );
				wk->cur_pos = 4;
				WazaInfoChange( wk );
			}
			break;

		case 5:
			Snd_SePlay( PST_SE_RET_BUTTON );
			wk->cur_pos = 5;
			wk->dat->ret_sel = 4;
			wk->dat->ret_mode = PST_RET_DECIDE;
			return RetButtonAnmSet( wk, SEQ_OUT_SET );

		default:
			if( HidenWazaCheck( wk->pp.waza[ret] ) == TRUE && wk->dat->waza != 0 ){
				Snd_SePlay( PST_SE_DECIDE );
				wk->cur_pos = ret;
				CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_KIND], 0 );
				PokeStatus_WazaCursorMove( wk );
				PokeStatus_WazaOboeErrorMsgPut( wk );
				return SEQ_WAZA_OBOE;
			}else{
				if( wk->pp.waza[ret] != 0 ){
					Snd_SePlay( PST_SE_DECIDE );
					wk->cur_pos = ret;
					WazaInfoChange( wk );
					return WazaAddCheckSet( wk );
				}
			}
		}
	}

	return SEQ_WAZA_OBOE;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：技覚え/忘れ最終確認
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqWazaAddCheck( PST_WORK * wk )
{
	if( sys.trg & PAD_BUTTON_DECIDE ){
		Snd_SePlay( PST_SE_DECIDE );
		wk->dat->ret_sel = wk->cur_pos;
		wk->dat->ret_mode = PST_RET_DECIDE;
		return WazaOboeCheckButtonAnmSet( wk, SEQ_OUT_SET );
	}

	if( sys.trg & PAD_BUTTON_CANCEL ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		CLACT_AnmChg( wk->awp[PST_OBJ_WAZACURSOR1], 0 );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
		WazaAddCheckScrnChange( wk, FALSE );
		return RetButtonAnmSet( wk, SEQ_WAZA_OBOE );
	}

	// タッチ
	switch( WazaSetCheckTouchCheck(wk) ){
	case 0:
		Snd_SePlay( PST_SE_DECIDE );
		wk->dat->ret_sel = wk->cur_pos;
		wk->dat->ret_mode = PST_RET_DECIDE;
		return WazaOboeCheckButtonAnmSet( wk, SEQ_OUT_SET );

	case 1:
		Snd_SePlay( PST_SE_RET_BUTTON );
		CLACT_AnmChg( wk->awp[PST_OBJ_WAZACURSOR1], 0 );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 0 );
		WazaAddCheckScrnChange( wk, FALSE );
		return RetButtonAnmSet( wk, SEQ_WAZA_OBOE );

	case RECT_HIT_NONE:
		break;
	}

	return SEQ_WAZA_OBOE_CHECK;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：リボン説明イン待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqRibbonIn( PST_WORK * wk )
{
	if( RibbonInfoScrollIn( wk ) == TRUE ){
		return SEQ_RIBBON_SELECT;
	}
	return SEQ_RIBBON_IN;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：リボン説明アウト待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqRibbonOut( PST_WORK * wk )
{
	if( RibbonInfoScrollOut( wk ) == TRUE ){
		return SEQ_MAIN;
	}
	return SEQ_RIBBON_OUT;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：リボン選択
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqRibbonSelect( PST_WORK * wk )
{
	if( sys.repeat & PAD_KEY_LEFT ){
		RibbonSelect( wk, -1 );
		return SEQ_RIBBON_SELECT;
	}
	if( sys.repeat & PAD_KEY_RIGHT ){
		RibbonSelect( wk, 1 );
		return SEQ_RIBBON_SELECT;
	}

	if( sys.repeat & PAD_KEY_UP ){
		RibbonSelect( wk, -3 );
		return SEQ_RIBBON_SELECT;
	}
	if( sys.repeat & PAD_KEY_DOWN ){
		RibbonSelect( wk, 3 );
		return SEQ_RIBBON_SELECT;
	}

	if( sys.trg & (PAD_BUTTON_CANCEL|PAD_BUTTON_DECIDE) ){
		Snd_SePlay( PST_SE_RET_BUTTON );
		return RibbonSelEndButtonAnmSet( wk, SEQ_RIBBON_OUT );
	}

	{	// タッチ
		int	ret = RibbonSelectTouchCkeck( wk );
		switch( ret ){
		case 9:
			if( CLACT_GetDrawFlag( wk->awp[PST_OBJ_RIBBON_AU] ) == 1 ){
				Snd_SePlay( PST_SE_CURSOR_MOVE );
				CLACT_AnmChg( wk->awp[PST_OBJ_RIBBON_AU], 2 );
				return SEQ_RIBBON_SCROLL_UP;
			}
			break;

		case 10:
			if( CLACT_GetDrawFlag( wk->awp[PST_OBJ_RIBBON_AD] ) == 1 ){
				Snd_SePlay( PST_SE_CURSOR_MOVE );
				CLACT_AnmChg( wk->awp[PST_OBJ_RIBBON_AD], 3 );
				return SEQ_RIBBON_SCROLL_DOWN;
			}
			break;

		case 11:
			Snd_SePlay( PST_SE_RET_BUTTON );
			return RibbonSelEndButtonAnmSet( wk, SEQ_RIBBON_OUT );

		case RECT_HIT_NONE:
			break;

		default:
			if( wk->ribbon_pos != ret ){
				wk->ribbon_pos = ret;
				Snd_SePlay( PST_SE_CURSOR_MOVE );
				RibbonSelect( wk, 0 );
			}
			return SEQ_RIBBON_SELECT;
		}
	}

	return SEQ_RIBBON_SELECT;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：リボンスクロール（上）
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqRibbonScrollUp( PST_WORK * wk )
{
	if( CLACT_AnmActiveCheck( wk->awp[PST_OBJ_RIBBON_AU] ) == FALSE ){
		RibbonSelect( wk, -9 );
		return SEQ_RIBBON_SELECT;
	}
	return SEQ_RIBBON_SCROLL_UP;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：リボンスクロール（下）
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqRibbonScrollDown( PST_WORK * wk )
{
	if( CLACT_AnmActiveCheck( wk->awp[PST_OBJ_RIBBON_AD] ) == FALSE ){
		RibbonSelect( wk, 9 );
		return SEQ_RIBBON_SELECT;
	}
	return SEQ_RIBBON_SCROLL_DOWN;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：コンディションアップ初期設定
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqCondUpInit( PST_WORK * wk )
{
	if( sys.trg & (PAD_BUTTON_DECIDE|PAD_BUTTON_CANCEL) ){
		POKEMON_PASO_PARAM * ppp;
		POKEMON_PARAM * pp;
		u8	tmp;

		if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
			ppp = PokeStatusPokeParamGet( wk );
			pp  = PokemonParam_AllocWork( HEAPID_POKESTATUS );
			PokeReplace( ppp, pp );
		}else{
			pp = PokeStatusPokeParamGet( wk );
		}

		wk->sub_seq = 0;

		// かっこよさ
		tmp = wk->pp.style;
		wk->pp.style = (u8)PokeParaGet( pp, ID_PARA_style, NULL );
		if( tmp != wk->pp.style ){
			wk->sub_seq |= 1;
		}

		// うつくしさ
		tmp = wk->pp.beautiful;
		wk->pp.beautiful = (u8)PokeParaGet( pp, ID_PARA_beautiful, NULL );
		if( tmp != wk->pp.beautiful ){
			wk->sub_seq |= 2;
		}

		// かわいさ
		tmp = wk->pp.cute;
		wk->pp.cute = (u8)PokeParaGet( pp, ID_PARA_cute, NULL );
		if( tmp != wk->pp.cute ){
			wk->sub_seq |= 4;
		}

		// かしこさ
		tmp = wk->pp.clever;
		wk->pp.clever = (u8)PokeParaGet( pp, ID_PARA_clever, NULL );
		if( tmp != wk->pp.clever ){
			wk->sub_seq |= 8;
		}

		// たくましさ
		tmp = wk->pp.strong;
		wk->pp.strong = (u8)PokeParaGet( pp, ID_PARA_strong, NULL );
		if( tmp != wk->pp.strong ){
			wk->sub_seq |= 16;
		}

		wk->pp.fur = (u8)PokeParaGet( pp, ID_PARA_fur, NULL );	// 毛艶

		if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
			sys_FreeMemoryEz( pp );
		}

		// 会話ウィンドウセット
		TalkFontPaletteLoad( PALTYPE_MAIN_BG, PST_PAL_TALKFONT * 32, HEAPID_POKESTATUS );
		TalkWinGraphicSet(
			wk->bgl, GF_BGL_FRAME1_M, PST_CGX_TALKWIN,
			PST_PAL_TALKWIN, CONFIG_GetWindowType(wk->dat->cfg), HEAPID_POKESTATUS );

		if( wk->sub_seq == 0 ){
			PokeStatus_CondUpMsgPut( wk, PST_MSG_PRMNONE );
			return SEQ_COND_END;
		}else{
			PokeStatus_ConditionParamMake( wk );
			PokeStatus_KezuyaInit( wk );
			PokeStatus_CondUpObjPut( wk );
			return SEQ_COND_MSG;
		}
	}
	return SEQ_COND_INIT;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：コンディションアップメッセージセット
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqCondUpMsgPut( PST_WORK * wk )
{
	u8	i;

	if( sys.trg & (PAD_BUTTON_DECIDE|PAD_BUTTON_CANCEL) ){
		for( i=0; i<5; i++ ){
			if( ( wk->sub_seq & (1<<i) ) ){
				PokeStatus_CondUpMsgPut( wk, i );
				wk->sub_seq ^= (1<<i);
				if( wk->sub_seq == 0 ){
					return SEQ_COND_END;
				}
				break;
			}
		}
	}
	return SEQ_COND_MSG;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：コンディションアップ終了
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqCondUpEnd( PST_WORK * wk )
{
	if( sys.trg & (PAD_BUTTON_DECIDE|PAD_BUTTON_CANCEL) ){
//		Snd_SePlay( PST_SE_CANCEL );
		return SEQ_OUT_SET;
	}
	return SEQ_COND_END;
}


//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：終了フェードセット
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static u8 PST_SeqOutSet( PST_WORK * wk )
{
	APP_WipeStart( APP_WIPE_OUT, HEAPID_POKESTATUS );
	return SEQ_OUT;
}


//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：終了フェード待ち
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static u8 PST_SeqOut( PST_WORK * wk )
{
	if( WIPE_SYS_EndCheck() == TRUE ){
		return TRUE;
	}
	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：ボタンアニメ
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqButtonAnm( PST_WORK * wk )
{
	switch( wk->sub_seq ){
	case 0:
		GF_BGL_ScrPalChange(
			wk->bgl, wk->button_frm,
			wk->button_px, wk->button_py, wk->button_sx, wk->button_sy, wk->button_pal1 );
		GF_BGL_LoadScreenV_Req( wk->bgl, wk->button_frm );
		wk->sub_seq++;
		break;

	case 1:
		wk->button_cnt++;
		if( wk->button_cnt != 4 ){ break; }
		GF_BGL_ScrPalChange(
			wk->bgl, wk->button_frm,
			wk->button_px, wk->button_py, wk->button_sx, wk->button_sy, wk->button_pal2 );
		GF_BGL_LoadScreenV_Req( wk->bgl, wk->button_frm );
		wk->button_cnt = 0;
		wk->sub_seq++;
		break;

	case 2:
		wk->button_cnt++;
		if( wk->button_cnt == 2 ){
			wk->sub_seq = 0;
			return wk->button_next;
		}
	}
	return SEQ_BUTTON_ANM;
}

//--------------------------------------------------------------------------------------------
/**
 * メインシーケンス：ボックス用ポケモンタッチ切り替え
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_SeqPokeChangeTouch( PST_WORK * wk )
{
	if( wk->button_py == BOX_POKECHG_BUTTON_UPY ){
		PokeChange( wk, -1 );
	}else{
		PokeChange( wk, 1 );
	}
	BoxPokeChangeArrowPut( wk );
	return SEQ_POKE_CHANGE;
}


//============================================================================================
//	ツール
//============================================================================================

//--------------------------------------------------------------------------------------------
/**
 * ポケモンデータ取得
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeDataSet( PST_WORK * wk )
{
	void * pp = PokeStatusPokeParamGet( wk );

	if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
		PokeDataSet_PokePasoParam( wk, pp, &wk->pp );
	}else{
		PokeDataSet_PokemonParam( wk, pp, &wk->pp );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモンデータ取得 ( POKEMON_PASO_PARAM版 )
 *
 * @param	wk		ステータス画面ワーク
 * @param	ppp		POKEMON_PASO_PARAM
 * @param	dat		データ格納場所
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeDataSet_PokePasoParam(
				PST_WORK * wk, POKEMON_PASO_PARAM * ppp, PST_POKEDATA * dat )
{
	POKEMON_PARAM * pp = PokemonParam_AllocWork( HEAPID_POKESTATUS );

	PokeReplace( ppp, pp );
	PokeDataSet_PokemonParam( wk, pp, dat );
	sys_FreeMemoryEz( pp );
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモンデータ取得 ( POKEMON_PARAM版 )
 *
 * @param	wk		ステータス画面ワーク
 * @param	pp		POKEMON_PARAM
 * @param	dat		データ格納場所
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeDataSet_PokemonParam(
				PST_WORK * wk, POKEMON_PARAM * pp, PST_POKEDATA * dat )
{
	POKEMON_PASO_PARAM * ppp;
	u16	i;
	u8	pp_count;
	BOOL	fast_flg;

	fast_flg = PokeParaFastModeOn( pp );

	dat->mons = (u16)PokeParaGet( pp, ID_PARA_monsno, NULL );

	ppp = PPPPointerGet(pp);

	MSGMAN_GetString( wk->msg_man, mes_status_02_05, wk->msg_buf );
	WORDSET_RegisterPokeMonsName( wk->wset, 0, ppp );
	WORDSET_ExpandStr( wk->wset, wk->pp.monsname, wk->msg_buf );

	MSGMAN_GetString( wk->msg_man, mes_status_01_01, wk->msg_buf );
	WORDSET_RegisterPokeNickName( wk->wset, 0, ppp );
	WORDSET_ExpandStr( wk->wset, wk->pp.nickname, wk->msg_buf );

	MSGMAN_GetString( wk->msg_man, mes_status_02_08, wk->msg_buf );
	WORDSET_RegisterPokeOyaName( wk->wset, 0, ppp );
	WORDSET_ExpandStr( wk->wset, wk->pp.oya, wk->msg_buf );

	dat->item = (u16)PokeParaGet( pp, ID_PARA_item, NULL );
	dat->lv   = (u8)PokeParaGet( pp, ID_PARA_level, NULL );

	dat->tamago = PokeParaGet( pp, ID_PARA_tamago_flag, NULL );

	if( PokeParaGet( pp, ID_PARA_nidoran_nickname, NULL ) == TRUE && dat->tamago == 0 ){
		dat->sex_put = 0;
	}else{
		dat->sex_put = 1;
	}

	dat->sex = PokeSexGet( pp );
	dat->ball = (u8)PokeParaGet( pp, ID_PARA_get_ball, NULL );

	dat->type1 = (u8)PokeParaGet( pp, ID_PARA_type1, NULL );
	dat->type2 = (u8)PokeParaGet( pp, ID_PARA_type2, NULL );

	dat->id = PokeParaGet( pp, ID_PARA_id_no, NULL );
	dat->now_exp  = PokeParaGet( pp, ID_PARA_exp, NULL );

	dat->oya_sex = (u8)PokeParaGet( pp, ID_PARA_oyasex, NULL );

	dat->now_lv_exp  = PokeLevelExpGet( dat->mons, dat->lv );
	if( dat->lv == 100 ){
		dat->next_lv_exp = dat->now_lv_exp;
	}else{
		dat->next_lv_exp = PokeLevelExpGet( dat->mons, dat->lv+1 );
	}

	dat->hp  = (u16)PokeParaGet( pp, ID_PARA_hp, NULL );
	dat->mhp = (u16)PokeParaGet( pp, ID_PARA_hpmax, NULL );
	dat->atc = (u16)PokeParaGet( pp, ID_PARA_pow, NULL );
	dat->def = (u16)PokeParaGet( pp, ID_PARA_def, NULL );
	dat->spa = (u16)PokeParaGet( pp, ID_PARA_spepow, NULL );
	dat->spd = (u16)PokeParaGet( pp, ID_PARA_spedef, NULL );
	dat->agi = (u16)PokeParaGet( pp, ID_PARA_agi, NULL );

	dat->tokusei = (u8)PokeParaGet( pp, ID_PARA_speabino, NULL );
	dat->seikaku = PokeSeikakuGet( pp );

	for( i=0; i<4; i++ ){
		dat->waza[i] = (u16)PokeParaGet( pp, ID_PARA_waza1+i, NULL );
		dat->wpp[i]  = (u8)PokeParaGet( pp, ID_PARA_pp1+i, NULL );
		pp_count = (u8)PokeParaGet( pp, ID_PARA_pp_count1+i, NULL );
		dat->mpp[i]  = WT_PPMaxGet( dat->waza[i], pp_count );
	}

	dat->style     = (u8)PokeParaGet( pp, ID_PARA_style, NULL );		// かっこよさ
	dat->beautiful = (u8)PokeParaGet( pp, ID_PARA_beautiful, NULL );	// うつくしさ
	dat->cute      = (u8)PokeParaGet( pp, ID_PARA_cute, NULL );			// かわいさ
	dat->clever    = (u8)PokeParaGet( pp, ID_PARA_clever, NULL );		// かしこさ
	dat->strong    = (u8)PokeParaGet( pp, ID_PARA_strong, NULL );		// たくましさ
	dat->fur       = (u8)PokeParaGet( pp, ID_PARA_fur, NULL );			// 毛艶

	dat->like = PST_LIKE_TASTE_NONE;
	for( i=0; i<5; i++ ){
		if( PokeParaLikeTasteCheck(pp,i) == 1 ){
			dat->like = i;
			break;
		}
	}

	dat->mark = PokeParaGet( pp, ID_PARA_mark, NULL );

	dat->form = PokeParaGet( pp, ID_PARA_form_no, NULL );

	dat->st = BadStatusIconAnmGet( pp );

	if( PokeParaPokerusedCheck( pp) == TRUE ){
		dat->pokerus = 2;
	}else if( PokeParaPokerusCheck( pp ) == TRUE ){
		dat->pokerus = 1;
		if( dat->st == ST_ICON_NONE ){
			dat->st = ST_ICON_POKERUS;
		}
	}else{
		dat->pokerus = 0;
	}

	if( PokeRareGet( pp ) == TRUE ){
		MORI_PRINT("レア!\n");
		dat->rare = 1;
	}else{
		MORI_PRINT("レアじゃない\n");
		dat->rare = 0;
	}

	dat->ribbon[0] = 0;
	dat->ribbon[1] = 0;
	dat->ribbon[2] = 0;
	dat->ribbon[3] = 0;
	wk->ribbon_max = 0;
	for( i=0; i<RIBBON_MAX; i++ ){
		if( PokeParaGet( pp, RIBBON_DataGet(i,RIBBON_PARA_POKEPARA), NULL ) != 0 ){
			dat->ribbon[i/32] |= (1<<(i&0x1f));
			wk->ribbon_max++;
		}
	}

/**** テスト!!! ****/
/*
	dat->ribbon[0] = 0xffffffff;
	dat->ribbon[1] = 0xffffffff;
	dat->ribbon[2] = 0xffff;
	wk->ribbon_max = 80;
*/
/*******************/

	// はっぱフラグ取得
	for(i=0;i<6;i++){
		wk->pp.leaf[i] = PokeParaGet(pp, ID_PARA_leaf0+i, NULL );
	}

	PokeParaFastModeOff( pp, fast_flg );
}

//--------------------------------------------------------------------------------------------
/**
 * 鳴き声再生
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	移行するシーケンス
 */
//--------------------------------------------------------------------------------------------
static void PST_PokeVoicePlay( PST_WORK * wk )
{
	u8 wait;

	if( wk->pp.tamago != 0 ){ return; }

	PokeEditData_VoiceWaitSet( wk->handle, &wait, wk->pp.mons, CLIENT_TYPE_BB );

	if( wk->pp.mons == MONSNO_PERAPPU ){
		//ペラップのポインタが必要になります
		Snd_PerapVoiceWaitPlay( wk->dat->perap, PM_MALE, PV_VOL_DEFAULT, 0, wait );
	}else{
		Snd_PMVoiceWaitPlay( wk->pp.mons, wait, wk->pp.form );	//PLATINUM_MERGE
	}
}


//--------------------------------------------------------------------------------------------
/**
 * 初期ページセット
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void InitPageSet( PST_WORK * wk )
{
	switch( wk->dat->mode ){
	case PST_MODE_NORMAL:		// 通常
	case PST_MODE_NO_WAZACHG:	// 技入れ替え不可
//		if( wk->pp.tamago == 0 ){
			wk->page = PST_PAGE_INFO_MEMO;
//		}else{
//			wk->page = PST_PAGE_MEMO;
//		}
		break;
	case PST_MODE_WAZAADD:		// 技覚え/技忘れ
		wk->page = PST_PAGE_PARAM_B_SKILL;
		break;
	}

	PokeStatusTabPosChg( wk );			// タブOBJ切り替え
	PokeStatus_PageTypeIconDraw( wk );	// 属性アイコンセット
	PokeStatus_RibbonInit( wk );		// リボン
	PokeStatus_MarkChg( wk );

	PokeStatus_KezuyaInit( wk );

	PokeStatus_PageBmpAdd( wk );
	PokeStatus_PageBmpPut( wk );

	PageBgScreenChg( wk );				// BG切り替え
	PokeLeaf_Draw( wk );

	if( wk->dat->mode == PST_MODE_WAZAADD ){
		WazaInfoPut( wk );
	}else{
		PSTOBJ_PokeCursorPut( wk );
		PSTOBJ_BoxPokeIconMove( wk );
		PSTOBJ_BoxPokeIconChg( wk );
	}
}


//--------------------------------------------------------------------------------------------
/**
 * ページ作成
 *
 * @param	dat		ステータス画面データ
 * @param	tbl		ページテーブル
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void PokeStatus_PageSet( PSTATUS_DATA * dat, const u8 * tbl )
{
	u8	i;

	dat->page_flg = 0;
	for( i=0; i<PST_PAGE_MAX; i++ ){
		if( tbl[i] == PST_PAGE_MAX ){ break; }
		dat->page_flg |= (1<<tbl[i]);
	}
}

//--------------------------------------------------------------------------------------------
/**
 * ページチェック
 *
 * @param	wk		ステータス画面ワーク
 * @param	pos		チェックページ
 *
 * @retval	"0 = 表示不可"
 * @retval	"0 != 表示可"
 */
//--------------------------------------------------------------------------------------------
u8 PokeStatus_PageCheck( PST_WORK * wk, u32 pos )
{
	if( wk->pp.tamago != 0 && pos != PST_PAGE_INFO_MEMO ){
		return 0;
	}
	return ( wk->dat->page_flg & (1<<pos) );
}

//--------------------------------------------------------------------------------------------
/**
 * ページ数取得
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	ページ数
 */
//--------------------------------------------------------------------------------------------
u8 PokeStatus_PageNumGet( PST_WORK * wk )
{
	u8	i, cnt;

	cnt = 0;
	for( i=0; i<PST_PAGE_MAX; i++ ){
		if( wk->dat->page_flg & (1<<i) ){
			cnt++;
		}
	}
	return cnt;

}


//--------------------------------------------------------------------------------------------
/**
 * ページ切り替え表示
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	次のページ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PageChangeWrite( PST_WORK * wk, u8 next )
{
	if( wk->page == next ){return; }

	// ページ表示用に確保していたBMPを解放
	PokeStatus_PageBmpFree( wk );
	wk->page = next;

	// タブ表示変更
	PokeStatusTabPosChg( wk );

	// タイプアイコン（ポケモンorわざ)のOAM表示設定
	PokeStatus_PageTypeIconDraw( wk );

	// ポケスロンパフォーマンス値表示
	PokePerformance_PageIconDraw( wk );
	PokeLeaf_Draw( wk );

	// リボン
	PokeStatus_RibbonInit( wk );

	// けづや
	PokeStatus_KezuyaInit( wk );

	// 各ページで必要とされるBMPの追加登録
	PokeStatus_PageBmpAdd( wk );

	// 文字列表示面の一旦消去
	GF_BGL_ScrFill(
		wk->bgl, GF_BGL_FRAME1_M, 0,
		PAGE_PRM_AREA_PX, PAGE_PRM_AREA_PY, PAGE_PRM_AREA_SX, PAGE_PRM_AREA_SY, 0 );
	GF_BGL_LoadScreenReq( wk->bgl, GF_BGL_FRAME1_M );	// 即転送
	// 文字列表示面の一旦消去
	GF_BGL_ScrFill(
		wk->bgl, GF_BGL_FRAME0_S, 0,
		PAGE_PRM_AREA_PX, PAGE_PRM_AREA_PY, PAGE_PRM_AREA_SX, PAGE_PRM_AREA_SY, 0 );
	GF_BGL_LoadScreenReq( wk->bgl, GF_BGL_FRAME0_S );	// 即転送

	// 追加BMPWINに文字列表示
	PokeStatus_PageBmpPut( wk );

	// ページ更新
	PageBgScreenChg( wk );

	if( wk->dat->mode == PST_MODE_WAZAADD ){
		PST_WazaSetInfoChange( wk );
	}
}


//------------------------------------------------------------------
/**
 * @brief   直接ページ変更
 *
 * @param	wk		ステータス画面ワーク
 * @param   page	ページ番号
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void PageDirectChange( PST_WORK * wk, s8 page )
{
	Snd_SePlay( PST_SE_PAGE_MOVE );
	PageChangeWrite( wk, page );

}
//--------------------------------------------------------------------------------------------
/**
 * ページ切り替え
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		切り替え方向
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PageChange( PST_WORK * wk, s8 mv )
{
	s8	next = wk->page;

	if( wk->pp.tamago != 0 ){ return; }

	while(1){
		next += mv;
		if( next < PST_PAGE_INFO_MEMO ){
			next = PST_PAGE_RIBBON;
		}else if( next > PST_PAGE_RIBBON ){
			next = PST_PAGE_INFO_MEMO;
		}
		if( ( wk->dat->page_flg & (1<<next) ) != 0 ){
			break;
		}
	}

	if( next == wk->page ){ return; }

	PageDirectChange( wk, next );
}

//------------------------------------------------------------------
/**
 * @brief   タブで選択されたページが存在しているか？
 *
 * @param	wk		ステータス画面ワーク
 * @param   page	ページ指定
 *					PST_PAGE_INFO_MEMO,PST_PAGE_PARAM_B_SKILL,PST_PAGE_RIBBON
 *
 * @retval  int		1:存在	0:無し
 */
//------------------------------------------------------------------
static int _page_change_check( PST_WORK *wk, int page )
{
	if(wk->dat->page_flg & (1<<page)){
		return 1;
	}
	return 0;
}

//--------------------------------------------------------------------------------------------
/**
 * 下画面ページ切り替え
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int SubButtonPageChg( PST_WORK * wk )
{
	u8	ret = PokeStatus_SubBottonPageGet( wk );

	if( ret == 0xff ){
		return SEQ_MAIN;
	}

	switch( ret ){
	case PST_PAGE_INFO_MEMO:
		if(_page_change_check(wk, ret)){
			PageDirectChange(wk, ret);
		}
		break;

	case PST_PAGE_PARAM_B_SKILL:
	case PST_PAGE_RIBBON:
		if( wk->pp.tamago != 0 ){ break; }
		if(_page_change_check(wk, ret)){
			PageDirectChange(wk, ret);
		}
		break;

	case PST_PAGE_RET:
		_set_keytouch_status( wk, APP_END_TOUCH );
		Snd_SePlay( PST_SE_RET_BUTTON );
		return RetButtonAnmSet( wk, SEQ_OUT_SET );

	case PST_POKE1:
	case PST_POKE2:
	case PST_POKE3:
	case PST_POKE4:
	case PST_POKE5:
	case PST_POKE6:
		if( wk->dat->pos == (ret-PST_POKE1) ){
			break;
		}
		if(PokePartyCheck(wk, ret-PST_POKE1)){
			PokeDirectChange(wk, ret-PST_POKE1);
			return SEQ_POKE_CHANGE;
		}
		break;
	}

	return SEQ_MAIN;
}


static const int pst_page_table[][3]={
	{ NARC_pst2_gra_ps_tmemo_up_nscr,  NARC_pst2_gra_ps_tmemo_dw_nscr, NARC_pst2_gra_ps_tmemo_dw_tamago_nscr },
	{ NARC_pst2_gra_ps_waza_up_nscr,   NARC_pst2_gra_ps_waza_dw_nscr,  NARC_pst2_gra_ps_waza_dw2_nscr,       },
	{ NARC_pst2_gra_ps_ribbon_up_nscr, NARC_pst2_gra_ps_ribbon_dw_nscr,NARC_pst2_gra_ps_ribbon_dw_nscr,      },
	{ NARC_pst2_gra_ps_tmemo_up_nscr,  NARC_pst2_gra_ps_tmemo_dw_nscr, NARC_pst2_gra_ps_tmemo_dw_nscr,       },
};

//------------------------------------------------------------------
/**
 * @brief   スクリーン転送設定
 *
 * @param	wk		ステータス画面ワーク
 * @param   bgl		BGL
 * @param   idx		ファイルインデックス
 * @param   bgno	ＢＧフレーム
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void PageScreenTransSet( PST_WORK * wk, GF_BGL_INI *bgl, int idx, int bgno )
{
	NNSG2dScreenData * dat;
	void * buf;

	OS_Printf("status page = %d\n", wk->page);

	buf = ArchiveDataLoadMalloc( ARC_POKESTATUS_GRA, idx, HEAPID_POKESTATUS );
	NNS_G2dGetUnpackedScreenData( buf, &dat );
	GF_BGL_ScrWrite( wk->bgl, bgno, dat->rawData, 0, 0, 32, 32 );
	GF_BGL_LoadScreenV_Req( bgl, bgno );
	sys_FreeMemoryEz( buf );

}


#define	BGWF_BOX_POKE_PX	( 20 )
#define	BGWF_BOX_POKE_PY	( 4 )

//--------------------------------------------------------------------------------------------
/**
 * ページBG切り替え
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PageBgScreenChg( PST_WORK * wk )
{

	// 上画面転送
	if(wk->dat->pokethlon==0  && wk->page==2){
		// ポケスロン用パフォーマンス画面を出すか？（タマゴの時は出さない）
		PageScreenTransSet( wk, wk->bgl, NARC_pst2_gra_ps_ribbon_up2_nscr, GF_BGL_FRAME3_M );
	}else{
		// 通常転送
		PageScreenTransSet( wk, wk->bgl, pst_page_table[wk->page][0], GF_BGL_FRAME3_M );
	}


	// 下画面
	if( wk->dat->mode == PST_MODE_WAZAADD ){
		// わざ５列表示
		PageScreenTransSet( wk, wk->bgl, pst_page_table[wk->page][2], GF_BGL_FRAME2_S );
		// サブページを表示
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, SUB_PAGE1_EX );
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_SET, SUB_PAGE1_EY );
		if( wk->dat->waza == 0 ){
			WazaDelScrnChange( wk );
		}
	}else{
		// ページ指定に合わせたページ
		if(wk->pp.tamago){
			PageScreenTransSet( wk, wk->bgl, pst_page_table[wk->page][2], GF_BGL_FRAME2_S );
		}else{
			if( _page_change_check( wk, PST_PAGE_RIBBON ) != 0 ){
				PageScreenTransSet( wk, wk->bgl, pst_page_table[wk->page][1], GF_BGL_FRAME2_S );
			}else{
				if( wk->page == PST_PAGE_INFO_MEMO ){
					PageScreenTransSet( wk, wk->bgl, NARC_pst2_gra_ps_tmemo_dw_nr_nscr, GF_BGL_FRAME2_S );
				}else{
					PageScreenTransSet( wk, wk->bgl, NARC_pst2_gra_ps_waza_dw_nr_nscr, GF_BGL_FRAME2_S );
				}
			}
		}
	}

	if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_BOX_POKE, BGWF_BOX_POKE_PX, BGWF_BOX_POKE_PY );
		BoxPokeChangeArrowPut( wk );
	}

	if( wk->pp.tamago == 0 ){
		if( wk->page == PST_PAGE_INFO_MEMO ){
			ExpGaugeSet( wk );
		}else if( wk->page == PST_PAGE_PARAM_B_SKILL ){
			HPGaugeSet( wk );
		}
	}
}


//--------------------------------------------------------------------------------------------
/**
 * HPゲージ表示
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void HPGaugeSet( PST_WORK * wk )
{
	u16	chr;
	u16	cgx;
	u8	dot;
	u8	i;

	switch( GetHPGaugeDottoColor( wk->pp.hp, wk->pp.mhp, HP_DOT_MAX ) ){
	case HP_DOTTO_MAX:		// 緑
	case HP_DOTTO_GREEN:
	case HP_DOTTO_NULL:
		chr = HP_CHR_GREEN | HP_CHR_PALETTE;
		break;
	case HP_DOTTO_YELLOW:	// 黄
		chr = HP_CHR_YELLOW | HP_CHR_PALETTE;
		break;
	case HP_DOTTO_RED:		// 赤
		chr = HP_CHR_RED | HP_CHR_PALETTE;
		break;
	}

	dot = GetNumDotto( wk->pp.hp, wk->pp.mhp, HP_DOT_MAX );

	for( i=0; i<HP_DOT_CHR_MAX; i++ ){
		if( dot >= 8 ){
			cgx = chr + 8;
		}else{
			cgx = chr + dot;
		}

		GF_BGL_ScrFill(
			wk->bgl, GF_BGL_FRAME3_M, cgx,
			HP_GAUGE_SCR_PX+i, HP_GAUGE_SCR_PY, 1, 1, GF_BGL_SCRWRT_PALIN );

		if( dot < 8 ){
			dot = 0;
		}else{
			dot -= 8;
		}
	}

	GF_BGL_LoadScreenV_Req( wk->bgl, GF_BGL_FRAME3_M );
}


//--------------------------------------------------------------------------------------------
/**
 * EXPゲージ表示
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void ExpGaugeSet( PST_WORK * wk )
{
	u32	max;
	u32	now;
	u16	cgx;
	u8	dot;
	u8	i;

/* ルビサファの育て屋でLv100以上の経験値になるため、マイナス表示になってしまう不具合対処 */
#if T1653_060815_FIX	// 対処後
	if( wk->pp.lv < 100 ){
		max = wk->pp.next_lv_exp - wk->pp.now_lv_exp;
		now = wk->pp.now_exp - wk->pp.now_lv_exp;
	}else{
		max = 0;
		now = 0;
	}
#else					// 対処前
	max = wk->pp.next_lv_exp - wk->pp.now_lv_exp;
	now = wk->pp.now_exp - wk->pp.now_lv_exp;
#endif	// T1653_060815_FIX

	dot = GetNumDotto( now, max, EXP_DOT_MAX );

	for( i=0; i<EXP_DOT_CHR_MAX; i++ ){
		if( dot >= 8 ){
			cgx = EXP_CGX + 8   + EXP_CHR_PALETTE;
		}else{
			cgx = EXP_CGX + dot + EXP_CHR_PALETTE;
		}

		GF_BGL_ScrFill(
			wk->bgl, GF_BGL_FRAME2_S, cgx,
			EXP_GAUGE_SCR_PX+i, EXP_GAUGE_SCR_PY, 1, 1, GF_BGL_SCRWRT_PALIN );

		if( dot < 8 ){
			dot = 0;
		}else{
			dot -= 8;
		}
	}

	GF_BGL_LoadScreenV_Req( wk->bgl, GF_BGL_FRAME2_S );
}


//------------------------------------------------------------------
/**
 * @brief   直接指定の手持ちポケモンのページに飛ぶ
  *
 * @param	wk		ステータス画面ワーク
 * @param   pos		ポケモン位置
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void PokeDirectChange( PST_WORK *wk, const u8 pos)
{
	wk->dat->pos = pos;

	PokeDataSet( wk );

	PST_PokeVoicePlay( wk );

	PokeStatus_NickNamePut( wk );
	PokeStatus_LvPut( wk );
	PokeStatus_ItemPut( wk );

	PageBgScreenChg( wk );

	PokeStatus_SoftSpriteReset( wk );

	PokeStatusTabPosChg( wk );

	PokeStatus_PokeTypeChange( wk );
	PokeStatus_PageTypeIconDraw( wk );

	// ポケスロンパフォーマンス値表示
	PokePerformance_PageIconDraw( wk );
	PokeLeaf_Draw( wk );

	PokeStatus_RibbonInit( wk );		// リボン
	PokeStasus_PokeIconChange( wk );
	PokeStatusBallAnmChg( wk );
	PokeStatus_StIconChg( wk );
	PokeStatus_KezuyaInit( wk );
	PokeStatus_MarkChg( wk );

	PokeStatus_PageBmpPut( wk );

	PSTOBJ_PokeCursorPut( wk );
	PSTOBJ_BoxPokeIconChg( wk );
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモン切り替え
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		切り替え方向
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PokeChange( PST_WORK * wk, s8 mv )
{
	s8	pos = PokeSearch( wk, mv );

	if( pos == -1 ){
		return;
	}

	PokeDirectChange( wk, pos );
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモン切り替えサーチ
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		切り替え方向
 *
 * @retval	"-1 = 切り替えられない"
 * @retval	"-1 != 切り替え位置"
 */
//--------------------------------------------------------------------------------------------
static s8 PokeSearch( PST_WORK * wk, s8 mv )
{
	switch( wk->dat->ppt ){
	case PST_PP_TYPE_POKEPARAM:	// POKEMON_PARAM
		return PokeSearch_PokemonParam( wk, mv );
	case PST_PP_TYPE_POKEPARTY:	// POKEPARTY
		return PokeSearch_PokeParty( wk, mv );
	case PST_PP_TYPE_POKEPASO:	// POKEMON_PASO_PARAM
		return PokeSearch_PokemonPasoParam( wk, mv );
	}
	return -1;
}

//------------------------------------------------------------------
/**
 * @brief   指定の場所には正しいポケモンが存在しているか？
 *
 * @param	wk		ステータス画面ワーク
 * @param   pos		位置
 *
 * @retval  int
 */
//------------------------------------------------------------------
static int PokePartyCheck( PST_WORK *wk, int pos )
{
	switch( wk->dat->ppt ){
	case PST_PP_TYPE_POKEPARAM:	// POKEMON_PARAM
		{
			POKEMON_PARAM *pp = (POKEMON_PARAM *)( (u32)wk->dat->ppd + PokemonParamSizeGet()*pos );
			// 開発NOが入っていて
			if( PokeParaGet( pp, ID_PARA_monsno, NULL ) != 0 ){
				// タマゴじゃなくて
				if( PokeParaGet( pp, ID_PARA_tamago_flag, NULL ) != 0 ){
					return TRUE;
				}
			}
		}
		break;
	case PST_PP_TYPE_POKEPARTY:	// POKEPARTY
		if( pos < wk->dat->max )
		{
			POKEMON_PARAM *pp = PokeParty_GetMemberPointer( wk->dat->ppd, pos );
			if( PokeParaGet( pp, ID_PARA_monsno, NULL ) != 0 ){
				if( PokeParaGet( pp, ID_PARA_tamago_flag, NULL ) != 0 ){
					if( PokeSearch_TamagoCheck( wk ) == TRUE ){
						return TRUE;
					}
				}else{
					return TRUE;
				}
			}
		}
		break;
	case PST_PP_TYPE_POKEPASO:	// POKEMON_PASO_PARAM
		{
			POKEMON_PASO_PARAM *ppp = (POKEMON_PASO_PARAM *)( (u32)wk->dat->ppd + PokemonPasoParamSizeGet()*pos );
			if( PokePasoParaGet( ppp, ID_PARA_monsno, NULL ) != 0 ){
				if( PokePasoParaGet( ppp, ID_PARA_tamago_flag, NULL ) != 0 ){
//					if( PokeSearch_TamagoCheck( wk ) == TRUE ){
						return TRUE;
//					}
				}
			}else{
				TRUE;
			}
		}
		break;
	}
	return FALSE;

}

//--------------------------------------------------------------------------------------------
/**
 * タマゴのチェックを許可するか
 *
 * @param	wk		ステータス画面ワーク
 *
 * @retval	"TRUE = あり"
 * @retval	"FALSE = なし"
 */
//--------------------------------------------------------------------------------------------
static BOOL PokeSearch_TamagoCheck( PST_WORK * wk )
{
	if( wk->dat->mode == PST_MODE_PORUTO ){
		return FALSE;
	}
	if( wk->page != PST_PAGE_INFO_MEMO && wk->page != PST_PAGE_RET ){
		return FALSE;
	}
	return TRUE;
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモンサーチ ( POKEMON_PARAM )
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		サーチ方向
 *
 * @retval	"-1 = 切り替えられない"
 * @retval	"-1 != 切り替え位置"
 */
//--------------------------------------------------------------------------------------------
static s8 PokeSearch_PokemonParam( PST_WORK * wk, s8 mv )
{
	POKEMON_PARAM * pp;
	s8	pos;

	pos = (s8)wk->dat->pos;
	pp  = (POKEMON_PARAM *)wk->dat->ppd;

	while(1){
		pos += mv;
		if( pos < 0 || pos >= wk->dat->max ){
			return -1;
		}
		pp = (POKEMON_PARAM *)( (u32)wk->dat->ppd + PokemonParamSizeGet()*pos );

		// 開発NOが入っていて
		if( PokeParaGet( pp, ID_PARA_monsno, NULL ) != 0 ){
			// タマゴじゃなくて
			if( PokeParaGet( pp, ID_PARA_tamago_flag, NULL ) != 0 ){
				// ポルトページじゃない
				if( PokeSearch_TamagoCheck( wk ) == TRUE ){
					break;
				}
			}else{
				break;
			}
		}
	}

	return pos;
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモンサーチ ( POKEPARTY )
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		サーチ方向
 *
 * @retval	"-1 = 切り替えられない"
 * @retval	"-1 != 切り替え位置"
 */
//--------------------------------------------------------------------------------------------
static s8 PokeSearch_PokeParty( PST_WORK * wk, s8 mv )
{
	POKEMON_PARAM * pp;
	s8	pos;

	pos = (s8)wk->dat->pos;

	while(1){
		pos += mv;
		if( pos < 0 || pos >= wk->dat->max ){
			return -1;
		}
		pp = PokeParty_GetMemberPointer( wk->dat->ppd, pos );
		if( PokeParaGet( pp, ID_PARA_monsno, NULL ) != 0 ){
			if( PokeParaGet( pp, ID_PARA_tamago_flag, NULL ) != 0 ){
				if( PokeSearch_TamagoCheck( wk ) == TRUE ){
					break;
				}
			}else{
				break;
			}
		}
	}

	return pos;
}

//--------------------------------------------------------------------------------------------
/**
 * ポケモンサーチ ( POKEMON_PASO_PARAM )
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		サーチ方向
 *
 * @retval	"-1 = 切り替えられない"
 * @retval	"-1 != 切り替え位置"
 */
//--------------------------------------------------------------------------------------------
static s8 PokeSearch_PokemonPasoParam( PST_WORK * wk, s8 mv )
{
	POKEMON_PASO_PARAM * ppp;
	s8	pos;

	pos = (s8)wk->dat->pos;
	ppp = (POKEMON_PASO_PARAM *)wk->dat->ppd;

	while(1){
		pos += mv;
		if( pos < 0 || pos >= wk->dat->max ){
			return -1;
		}
		ppp = (POKEMON_PASO_PARAM *)( (u32)wk->dat->ppd + PokemonPasoParamSizeGet()*pos );
		if( PokePasoParaGet( ppp, ID_PARA_monsno, NULL ) != 0 ){
			if( PokePasoParaGet( ppp, ID_PARA_tamago_flag, NULL ) != 0 ){
				if( PokeSearch_TamagoCheck( wk ) == TRUE ){
					break;
				}
			}else{
				break;
			}
		}
	}

	return pos;
}

//--------------------------------------------------------------------------------------------
/**
 * 選択中のポケモンのパラメータを取得
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	ポケモンパラメータのポインタ
 */
//--------------------------------------------------------------------------------------------
void * PokeStatusPokeParamGet( PST_WORK * wk )
{
	switch( wk->dat->ppt ){
	case PST_PP_TYPE_POKEPARAM:	// POKEMON_PARAM
		return (void *)( (u32)wk->dat->ppd + ( PokemonParamSizeGet()*wk->dat->pos ) );

	case PST_PP_TYPE_POKEPARTY:	// POKEPARTY
		return (void *)PokeParty_GetMemberPointer( wk->dat->ppd, wk->dat->pos );

	case PST_PP_TYPE_POKEPASO:	// POKEMON_PASO_PARAM
		return (void *)((u32)wk->dat->ppd+(PokemonPasoParamSizeGet()*wk->dat->pos));
	}
	return NULL;
}


//--------------------------------------------------------------------------------------------
/**
 * 技情報（戦闘）をスクロールイン
 *
 * @param	wk		ステータス画面ワーク
 *
 * @retval	"TRUE = 終了"
 * @retval	"FALSE = 処理中"
 */
//--------------------------------------------------------------------------------------------
static u8 WazaInfoScrollIn( PST_WORK * wk )
{
	switch( wk->sub_seq ){
	case 0:
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR1], 0 );
		CLACT_AnmChg( wk->awp[PST_OBJ_WAZACURSOR1], 0 );

		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, SUB_PAGE_SX );
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_SET, SUB_PAGE_SY );

		GF_BGL_BmpWinOffVReq( &wk->def_win[WIN_P5_TITLE] );
		wk->sub_seq = 1;
		break;
	case 1:
		{
			int	cnt = GF_BGL_ScrollGetX( wk->bgl, GF_BGL_FRAME1_S );

			if( cnt >= SUB_PAGE1_EX ){
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, SUB_PAGE1_EX );
				wk->sub_seq = 2;
			}else{
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_INC, SUB_PAGE1_MOVE );
			}
		}
		break;
	case 2:
		PokeStatus_SkillCancelPut( wk );
		WazaInfoChange( wk );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE1], 1 );
		PokeStatus_PokeIconSet( wk );
		if( wk->pp.type1 != wk->pp.type2 ){
			CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE2], 1 );
		}
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR1], 1 );
		wk->sub_seq = 0;
		return TRUE;
	}
	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技情報（戦闘）をスクロールアウト
 *
 * @param	wk		ステータス画面ワーク
 *
 * @retval	"TRUE = 終了"
 * @retval	"FALSE = 処理中"
 */
//--------------------------------------------------------------------------------------------
static u8 WazaInfoScrollOut( PST_WORK * wk )
{
	switch( wk->sub_seq ){
	case 0:
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE1], 0 );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE2], 0 );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_KIND], 0 );
		CATS_ObjectEnable( wk->awp[PST_OBJ_POKEICON], 0 );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR1], 0 );
		PokeStatus_SkillCancelDel( wk );
		PokeStatus_WazaInfoOff( wk );
		wk->sub_seq = 1;
		break;
	case 1:
		{
			int	cnt = GF_BGL_ScrollGetX( wk->bgl, GF_BGL_FRAME1_S );

			if( cnt <= SUB_PAGE1_EX ){
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, SUB_PAGE_SX );
				wk->sub_seq = 2;
			}else{
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_DEC, SUB_PAGE1_MOVE );
			}
		}
		break;
	case 2:
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_LV] );
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_MOTIMONO] );
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_ITEMNAME] );
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_P5_TITLE] );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR1], 1 );
		PSTOBJ_PokeCursorPut( wk );
		wk->sub_seq = 0;
		return TRUE;
	}
	return FALSE;
}


//--------------------------------------------------------------------------------------------
/**
 * 技カーソル移動
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		移動方向
 *
 * @retval	"TRUE = 移動した"
 * @retval	"FALSE = 移動しなかった"
 */
//--------------------------------------------------------------------------------------------
static u8 WazaCursorMove( PST_WORK * wk, s8 mv )
{
	s8	pos;
	s8	max;

	pos = wk->cur_pos;
	if( wk->dat->mode == PST_MODE_WAZAADD ){
		if( wk->dat->waza != 0 ){
			max = 4;
		}else{
			max = 3;
		}
	}else{
		max = 3;
	}

	while(1){
		pos += mv;
		if( pos < 0 ){
			pos = max;
		}else if( pos > max ){
			pos = 0;
		}
		if( pos == 4 ){
			break;
		}
		if( wk->pp.waza[pos] != 0 || pos == wk->cur_pos ){
			break;
		}
	}

	if( pos != wk->cur_pos ){
		wk->cur_pos = pos;
		return TRUE;
	}

	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技情報表示切替
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaInfoChange( PST_WORK * wk )
{
	PokeStatus_WazaCursorMove( wk );

	if( wk->cur_pos == 4 ){
		if( wk->dat->waza != 0 ){
			BattleWazaInfoChg( wk, wk->dat->waza );
		}else{
			BattleWazaInfoChg( wk, 0xffffffff );
		}
	}else if( wk->cur_pos == 5 ){
		BattleWazaInfoChg( wk, 0xffffffff );
	}else{
		BattleWazaInfoChg( wk, wk->pp.waza[wk->cur_pos] );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * 戦闘技情報表示切替
 *
 * @param	wk		ステータス画面ワーク
 * @param	waza	技番号
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BattleWazaInfoChg( PST_WORK * wk, u32 waza )
{
	if( waza == 0xffffffff ){
		PokeStatus_WazaInfoOff( wk );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_KIND], 0 );
	}else{
		PokeStatus_WazaInfoPut( wk, waza );
		PokeStatus_KindIconChange( wk, waza );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_KIND], 1 );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * 技入れ替え
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaChangeMain( PST_WORK * wk )
{
	void * pp;
	u16	tmp_waza;
	u8	tmp_wpp;
	u8	tmp_mpp;

	pp = PokeStatusPokeParamGet( wk );

	if( wk->dat->ppt == PST_PP_TYPE_POKEPASO ){
		PokePasoParaWazaReplace( pp, wk->cur_pos, wk->sub_cur );
	}else{
		PokeParaWazaReplace( pp, wk->cur_pos, wk->sub_cur );
	}

	tmp_waza = wk->pp.waza[wk->cur_pos];
	wk->pp.waza[wk->cur_pos] = wk->pp.waza[wk->sub_cur];
	wk->pp.waza[wk->sub_cur] = tmp_waza;

	tmp_wpp = wk->pp.wpp[wk->cur_pos];
	wk->pp.wpp[wk->cur_pos] = wk->pp.wpp[wk->sub_cur];
	wk->pp.wpp[wk->sub_cur] = tmp_wpp;

	tmp_mpp = wk->pp.mpp[wk->cur_pos];
	wk->pp.mpp[wk->cur_pos] = wk->pp.mpp[wk->sub_cur];
	wk->pp.mpp[wk->sub_cur] = tmp_mpp;

	wk->dat->waza_chg = TRUE;	// 技を入れ替えた
}

//--------------------------------------------------------------------------------------------
/**
 * 技情報表示
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaInfoPut( PST_WORK * wk )
{
	GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME2_M, GF_BGL_SCROLL_X_SET, 0 );

	PokeStatus_SkillCancelPut( wk );
	WazaInfoChange( wk );

	CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE1], 1 );
	PokeStatus_PokeIconSet( wk );
	if( wk->pp.type1 != wk->pp.type2 ){
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE2], 1 );
	}
	CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR1], 1 );
}

//--------------------------------------------------------------------------------------------
/**
 * 技選択モード時にページ切り替えされた時の技情報切り替え
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void PST_WazaSetInfoChange( PST_WORK * wk )
{
	PokeStatus_SkillCancelPut( wk );
	WazaInfoChange( wk );
	PokeStatus_PokeIconSet( wk );

	if( wk->page == PST_PAGE_PARAM_B_SKILL ){
		PokeStatus_EzConditionOff( wk );
		CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE1], 1 );
		if( wk->pp.type1 != wk->pp.type2 ){
			CATS_ObjectEnable( wk->awp[PST_OBJ_TYPE_POKE2], 1 );
		}
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME2_M, GF_BGL_SCROLL_Y_SET, 0 );
	}else{
		PokeStatus_EzConditionPut( wk );
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME2_M, GF_BGL_SCROLL_Y_SET, 256 );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * リボン情報をスクロールイン
 *
 * @param	wk		ステータス画面ワーク
 *
 * @retval	"TRUE = 終了"
 * @retval	"FALSE = 処理中"
 */
//--------------------------------------------------------------------------------------------
static u8 RibbonInfoScrollIn( PST_WORK * wk )
{
	switch( wk->sub_seq ){
	case 0:
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_X_SET, SUB_PAGE_SX );
		GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_SET, SUB_PAGE_SY );

		// ポケモンアイコンのカーソルの優先度を下げる
		CLACT_BGPriorityChg( wk->awp[PST_OBJ_WAZACURSOR1], 3 );
		// ポケモンアイコンのカーソルのカラーを変更
		CATS_ObjectPaletteSet( wk->awp[PST_OBJ_WAZACURSOR1], 0 );

		GF_BGL_BmpWinOffVReq( &wk->def_win[WIN_P7_MOTTEIRU] );
		GF_BGL_BmpWinOffVReq( &wk->def_win[WIN_P5_MODORU] );
		GF_BGL_BmpWinOffVReq( &wk->add_win[ADD_WIN_P7_NUM] );

		wk->ribbon_scr = 0;
		wk->sub_seq = 1;
		break;

	case 1:
		{
			int	cnt = GF_BGL_ScrollGetY( wk->bgl, GF_BGL_FRAME1_S );

			if( cnt >= SUB_PAGE2_EY ){
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_SET, SUB_PAGE2_EY );
				wk->sub_seq = 2;
			}else{
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_INC, SUB_PAGE2_MOVE );
			}
		}
		break;

	case 2:
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_CUR], 1 );
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_FLASH], 1 );
		RibbonSelect( wk, 0 );
		wk->sub_seq = 0;
		return TRUE;
	}

	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * リボン情報をスクロールアウト
 *
 * @param	wk		ステータス画面ワーク
 *
 * @retval	"TRUE = 終了"
 * @retval	"FALSE = 処理中"
 */
//--------------------------------------------------------------------------------------------
static u8 RibbonInfoScrollOut( PST_WORK * wk )
{
	switch( wk->sub_seq ){
	case 0:
		wk->ribbon_pos = 0;
		wk->ribbon_scr = 0;
		GF_BGL_BmpWinOffVReq( &wk->add_win[ADD_WIN_P7_NAME] );
		GF_BGL_BmpWinOffVReq( &wk->add_win[ADD_WIN_P7_INFO] );
		PokeStatus_RibbonInit( wk );
		wk->sub_seq = 1;
		break;

	case 1:
		{
			int	cnt = GF_BGL_ScrollGetY( wk->bgl, GF_BGL_FRAME1_S );

			if( cnt <= SUB_PAGE_SX ){
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_SET, SUB_PAGE_SY );
				wk->sub_seq = 2;
			}else{
				GF_BGL_ScrollReq( wk->bgl, GF_BGL_FRAME1_S, GF_BGL_SCROLL_Y_DEC, SUB_PAGE2_MOVE );
			}
		}
		break;
	case 2:
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_P7_MOTTEIRU] );
		GF_BGL_BmpWinOnVReq( &wk->def_win[WIN_P5_MODORU] );
		GF_BGL_BmpWinOnVReq( &wk->add_win[ADD_WIN_P7_NUM] );

		// ポケモンアイコンのカーソルの優先度を上げる
		CLACT_BGPriorityChg( wk->awp[PST_OBJ_WAZACURSOR1], 0 );
		// ポケモンアイコンのカーソルのカラーを変更
		CATS_ObjectPaletteSet( wk->awp[PST_OBJ_WAZACURSOR1], 2 );

		wk->sub_seq = 0;
		return TRUE;
	}

	return FALSE;
}

//--------------------------------------------------------------------------------------------
/**
 * リボン選択
 *
 * @param	wk		ステータス画面ワーク
 * @param	mv		移動方向
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void RibbonSelect( PST_WORK * wk, s8 mv )
{
	u8	cpy_pos;
	u8	cpy_scr;

	cpy_pos = wk->ribbon_pos;
	cpy_scr = wk->ribbon_scr;

	if( mv == 1 ){
		if( ( wk->ribbon_pos % 3 ) == 2 ){
			return;
		}
//		if( ( wk->ribbon_scr*9+wk->ribbon_pos+1 ) < wk->ribbon_max ){
			wk->ribbon_pos += 1;
//		}
	}else if( mv == -1 ){
		if( ( wk->ribbon_pos % 3 ) == 0 ){
			return;
		}
		wk->ribbon_pos -= 1;
	}else if( mv == 3 ){
		if( wk->ribbon_pos >= 6 ){
			if( ( (wk->ribbon_scr+1) * 9 ) < wk->ribbon_max ){
				wk->ribbon_scr++;
				wk->ribbon_pos %= 3;
			}
		}else{
//			if( ( wk->ribbon_scr * 9 + wk->ribbon_pos + 3 ) < wk->ribbon_max ){
				wk->ribbon_pos += 3;
//			}
		}
	}else if( mv == -3 ){
		if( wk->ribbon_pos <= 2 ){
			if( wk->ribbon_scr != 0 ){
				wk->ribbon_scr--;
				wk->ribbon_pos = wk->ribbon_pos % 3 + 6;
			}
		}else{
			wk->ribbon_pos -= 3;
		}
	}else if( mv == 9 ){
		if( ( ( wk->ribbon_scr + 1 ) * 9 ) < wk->ribbon_max ){
			wk->ribbon_scr++;
		}
	}else if( mv == -9 ){
		if( wk->ribbon_scr != 0 ){
			wk->ribbon_scr--;
		}
	}

	if( ( cpy_pos != wk->ribbon_pos || cpy_scr != wk->ribbon_scr ) && mv != 9 && mv != -9 ){
		Snd_SePlay( PST_SE_CURSOR_MOVE );
	}

	wk->ribbon_num = PokeStatus_RibbonPosIDGet( wk, wk->ribbon_pos );

	PokeStatus_RibbonCursorMove( wk );
	if( cpy_scr != wk->ribbon_scr ){
		PokeStatus_RibbonChange( wk );
	}
	PokeStatus_RibbonInfoPut( wk );

	if( wk->ribbon_scr != 0 ){
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_AU], 1 );
	}else{
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_AU], 0 );
	}
	if( ( wk->ribbon_scr*9+9 ) < wk->ribbon_max ){
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_AD], 1 );
	}else{
		CLACT_SetDrawFlag( wk->awp[PST_OBJ_RIBBON_AD], 0 );
	}
}

//--------------------------------------------------------------------------------------------
/**
 * 指定位置のリボンIDを取得
 *
 * @param	wk		ステータス画面ワーク
 * @param	cur_pos	位置
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
u8 PokeStatus_RibbonPosIDGet( PST_WORK * wk, u8 cur_pos )
{
	u16	i;
	u8	pos, cnt;

	pos = cur_pos + wk->ribbon_scr * 9;
	cnt = 0;

	for( i=0; i<RIBBON_MAX; i++ ){
		if( ( wk->pp.ribbon[i/32] & (1<<(i&0x1f)) ) != 0 ){
			if( pos == cnt ){
				return (u8)i;
			}
			cnt++;
		}
	}
	return 0;
}


//--------------------------------------------------------------------------------------------
/**
 * ポルトを食べられるか
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	次のシーケンス
 */
//--------------------------------------------------------------------------------------------
static int PST_PorutoEatCehck( PST_WORK * wk )
{
	if( wk->pp.fur == PST_KEDUYA_MAX ){
		// 会話ウィンドウセット
		TalkFontPaletteLoad( PALTYPE_MAIN_BG, PST_PAL_TALKFONT * 32, HEAPID_POKESTATUS );
		TalkWinGraphicSet(
			wk->bgl, GF_BGL_FRAME1_M, PST_CGX_TALKWIN,
			PST_PAL_TALKWIN, CONFIG_GetWindowType(wk->dat->cfg), HEAPID_POKESTATUS );
		PokeStatus_CondUpMsgPut( wk, PST_MSG_EATNONE );
		wk->dat->ret_mode = PST_RET_CANCEL;
		return SEQ_COND_END;
	}

	wk->dat->ret_mode = PST_RET_DECIDE;
	return SEQ_OUT_SET;
}


//--------------------------------------------------------------------------------------------
/**
 * プレイヤー情報セット
 *
 * @param	dat		ステータス画面データ
 * @param	my		MYSTATUS
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
void PokeStatus_PlayerSet( PSTATUS_DATA * dat, const MYSTATUS * my )
{
	dat->player_name = MyStatus_GetMyName( my );
	dat->player_id   = MyStatus_GetID( my );
	dat->player_sex  = (u8)MyStatus_GetMySex( my );
}


//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのアーカイブインデックスを取得（キャラ）
 *
 * @param	none
 *
 * @return	アーカイブインデックス
 */
//--------------------------------------------------------------------------------------------
u32 BadStatusIconCharArcGet(void)
{
	return NARC_pst_gra_p_st_ijou_NCGR;
}

//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのアーカイブインデックスを取得（パレット）
 *
 * @param	none
 *
 * @return	アーカイブインデックス
 */
//--------------------------------------------------------------------------------------------
u32 BadStatusIconPlttArcGet(void)
{
	return NARC_pst_gra_p_st_ijou_NCLR;
}

//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのアーカイブインデックスを取得（セル）
 *
 * @param	none
 *
 * @return	アーカイブインデックス
 */
//--------------------------------------------------------------------------------------------
u32 BadStatusIconCellArcGet(void)
{
	return NARC_pst_gra_p_st_ijou_NCER;
}

//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのアーカイブインデックスを取得（セルアニメ）
 *
 * @param	none
 *
 * @return	アーカイブインデックス
 */
//--------------------------------------------------------------------------------------------
u32 BadStatusIconCanmArcGet(void)
{
	return NARC_pst_gra_p_st_ijou_NANR;
}

//--------------------------------------------------------------------------------------------
/**
 * 状態異常アイコンのアニメ番号を取得
 *
 * @param	pp		ポケモンデータ
 *
 * @return	アニメ番号
 */
//--------------------------------------------------------------------------------------------
u32 BadStatusIconAnmGet( POKEMON_PARAM * pp )
{
	u32	prm = PokeParaGet( pp, ID_PARA_condition, NULL );

	// 瀕死
	if( PokeParaGet( pp, ID_PARA_hp, NULL ) == 0 ){
		return ST_ICON_HINSI;
	// 毒
	}else if( ( prm & (CONDITION_DOKU|CONDITION_DOKUDOKU) ) != 0 ){
		return ST_ICON_DOKU;
	// 眠り
	}else if( ( prm & CONDITION_NEMURI ) != 0 ){
		return ST_ICON_NEMURI;
	// 火傷
	}else if( ( prm & CONDITION_YAKEDO ) != 0 ){
		return ST_ICON_YAKEDO;
	// 氷
	}else if( ( prm & CONDITION_KOORI ) != 0 ){
		return ST_ICON_KOORI;
	// 麻痺
	}else if( ( prm & CONDITION_MAHI ) != 0 ){
		return ST_ICON_MAHI;
	}
	// なし
	return ST_ICON_NONE;
}


//------------------------------------------------------------------
/**
 * @brief   キータッチ状態の設定（NULLの時は代入しない）
 *
 * @param	wk			ステータス画面ワーク
 * @param   key_touch	キーかタッチか
 *
 * @retval  none
 */
//------------------------------------------------------------------
static void _set_keytouch_status( PST_WORK *wk, int key_touch )
{
	// NULLでなければキータッチ状態を入力する
	if(wk->dat->kt_status!=NULL){
		KeyTouchStatus_SetTouchOrKey( wk->dat->kt_status, key_touch );
	}

}




// タッチ座標テーブル：技選択（通常）
static const RECT_HIT_TBL NormalWazaHitTbl[] =
{
	{   8,  39,  8, 127 },
	{  40,  71,  8, 127 },
	{  72, 103,  8, 127 },
	{ 104, 135,  8, 127 },
	{ RECT_HIT_END, 0, 0, 0 }
};

static const RECT_HIT_TBL WazaChangeHitPos = { 136, 151,  8, 87 };
static const RECT_HIT_TBL WazaSet5thHitPos = { 152, 183,  8, 127 };
static const RECT_HIT_TBL WazaSetCancelHitPos = { 165, 188, 190, 249 };

// タッチ座標テーブル：ボックス用ポケモン切り替え矢印
static const RECT_HIT_TBL BoxPokeChangeHitTbl[] =
{
	{  40,  63, 192, 239 },
	{ 104, 127, 192, 239 },
	{ RECT_HIT_END, 0, 0, 0 }
};

// タッチ座標テーブル：リボン選択
static const RECT_HIT_TBL RibbonSelectHitTbl[] =
{
	{  8,  39, 16, 47 }, {  8,  39, 48, 79 }, {  8,  39, 80, 112 },
	{ 48,  79, 16, 47 }, { 48,  79, 48, 79 }, { 48,  79, 80, 112 },
	{ 88, 119, 16, 47 }, { 88, 119, 48, 79 }, { 88, 119, 80, 112 },

	{ 12,  51, 116, 139 },
	{ 76, 115, 116, 139 },

	{ 160, 191, 208, 255 },

	{ RECT_HIT_END, 0, 0, 0 }
};


//--------------------------------------------------------------------------------------------
/**
 * 技ページのタッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int NormalWazaPageTouchCheck( PST_WORK * wk )
{
	return GF_TP_RectHitTrg( NormalWazaHitTbl );
}

//--------------------------------------------------------------------------------------------
/**
 * 技選択タッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int NormalWazaSelectTouchCheck( PST_WORK * wk )
{
	int	ret = GF_TP_RectHitTrg( NormalWazaHitTbl );

	if( ret != RECT_HIT_NONE ){
		return ret;
	}

	//「やめる」
	if( GF_TP_SingleHitTrg( &WazaSetCancelHitPos ) == TRUE ){
		return 4;
	}

	return RECT_HIT_NONE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技入れ替えタッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int ChangeWazaSelectTouchCheck( PST_WORK * wk )
{
	int	ret = GF_TP_RectHitTrg( NormalWazaHitTbl );

	if( ret != RECT_HIT_NONE ){
		return ret;
	}

	//「いれかえ」
	if( GF_TP_SingleHitTrg( &WazaChangeHitPos ) == TRUE ){
		return 4;
	}

	//「やめる」
	if( GF_TP_SingleHitTrg( &WazaSetCancelHitPos ) == TRUE ){
		return 5;
	}

	return RECT_HIT_NONE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技覚え：技選択タッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int WazaSetSelectTouchCheck( PST_WORK * wk )
{
	int	ret = GF_TP_RectHitTrg( NormalWazaHitTbl );

	if( ret != RECT_HIT_NONE ){
		return ret;
	}

	// 新しく覚える技
	if( GF_TP_SingleHitTrg( &WazaSet5thHitPos ) == TRUE ){
		return 4;
	}

	//「やめる」
	if( GF_TP_SingleHitTrg( &WazaSetCancelHitPos ) == TRUE ){
		return 5;
	}

	return RECT_HIT_NONE;
}

//--------------------------------------------------------------------------------------------
/**
 * 技覚え最終確認タッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int WazaSetCheckTouchCheck( PST_WORK * wk )
{
	//「わすれる」
	if( GF_TP_SingleHitTrg( &WazaSet5thHitPos ) == TRUE ){
		return 0;
	}

	//「やめる」
	if( GF_TP_SingleHitTrg( &WazaSetCancelHitPos ) == TRUE ){
		return 1;
	}

	return RECT_HIT_NONE;
}

//--------------------------------------------------------------------------------------------
/**
 * ボックスポケモンの切り替えボタンタッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int BoxPokeChangeTouchCheck( PST_WORK * wk )
{
	return GF_TP_RectHitTrg( BoxPokeChangeHitTbl );
}

//--------------------------------------------------------------------------------------------
/**
 * リボン選択タッチチェック
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	タッチ情報
 */
//--------------------------------------------------------------------------------------------
static int RibbonSelectTouchCkeck( PST_WORK * wk )
{
	return GF_TP_RectHitTrg( RibbonSelectHitTbl );
}



//--------------------------------------------------------------------------------------------
/**
 * 技覚え最終確認へ
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	シーケンス：SEQ_WAZA_OBOE_CHECK
 */
//--------------------------------------------------------------------------------------------
static int WazaAddCheckSet( PST_WORK * wk )
{
//	wk->sub_cur = 0;

	CLACT_AnmChg( wk->awp[PST_OBJ_WAZACURSOR1], 1 );

	CLACT_SetDrawFlag( wk->awp[PST_OBJ_WAZACURSOR2], 1 );
	PSTOBJ_WazaAddSubCursorPut( wk );

	WazaAddCheckScrnChange( wk, TRUE );

	return SEQ_WAZA_OBOE_CHECK;
}

// 技覚えスクリーン書き換え
#define	WAZA_OBOE_CHECK_BUTTON_PX	( 0 )
#define	WAZA_OBOE_CHECK_BUTTON_PY	( 18 )
#define	WAZA_OBOE_CHECK_BUTTON_SX	( 17 )
#define	WAZA_OBOE_CHECK_BUTTON_SY	( 6 )
#define	WAZA_CHG_BUTTON_PX			( 1 )
#define	WAZA_CHG_BUTTON_PY			( 16 )
#define	WAZA_CHG_BUTTON_SX			( 10 )
#define	WAZA_CHG_BUTTON_SY			( 2 )

//--------------------------------------------------------------------------------------------
/**
 * 技覚えスクリーン書き換え
 *
 * @param	wk		ステータス画面ワーク
 * @param	flg		TRUE = 確認へ, FALSE = 技選択へ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaAddCheckScrnChange( PST_WORK * wk, BOOL flg )
{
	// 確認へ
	if( flg == TRUE ){
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_WAZADEL_BUTTON, WAZA_OBOE_CHECK_BUTTON_PX, WAZA_OBOE_CHECK_BUTTON_PY );

		CLACT_SetDrawFlag( wk->awp[PST_OBJ_TYPE_WAZA5], 0 );

		PSTBMP_WazaAddCheckSet( wk, TRUE );

	// 技選択へ
	}else{
		if( wk->dat->waza != 0 ){
			BGWINFRM_FramePut(
				wk->wfrm, PST_WFRM_5TH_WAZA, WAZA_OBOE_CHECK_BUTTON_PX, WAZA_OBOE_CHECK_BUTTON_PY );
			CLACT_SetDrawFlag( wk->awp[PST_OBJ_TYPE_WAZA5], 1 );
		}else{
			WazaDelScrnChange( wk );
		}
		PSTBMP_WazaAddCheckSet( wk, FALSE );
	}
}

#define	WAZA_DEL_SCRN_CHAR	( 0x3006 )

//--------------------------------------------------------------------------------------------
/**
 * 新規技なしのスクリーンへ
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaDelScrnChange( PST_WORK * wk )
{
	GF_BGL_ScrFill(
		wk->bgl, GF_BGL_FRAME2_S, WAZA_DEL_SCRN_CHAR,
		WAZA_OBOE_CHECK_BUTTON_PX, WAZA_OBOE_CHECK_BUTTON_PY,
		WAZA_OBOE_CHECK_BUTTON_SX, WAZA_OBOE_CHECK_BUTTON_SY, GF_BGL_SCRWRT_PALIN );
	GF_BGL_LoadScreenV_Req( wk->bgl, GF_BGL_FRAME2_S );
}

//--------------------------------------------------------------------------------------------
/**
 * 技入れ替えスクリーン書き換え
 *
 * @param	wk		ステータス画面ワーク
 * @param	flg		TRUE = 「いれかえ」へ, FALSE = 技選択へ
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void WazaChgCheckScrnChange( PST_WORK * wk, BOOL flg )
{
	if( wk->dat->mode == PST_MODE_NO_WAZACHG ){ return; }

	//「いれかえ」へ
	if( flg == TRUE ){
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_WAZACHG_BUTTON, WAZA_CHG_BUTTON_PX, WAZA_CHG_BUTTON_PY );

		PSTBMP_WazaChgCheckSet( wk, TRUE );

	// 技選択へ
	}else{
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_WAZA_NONE, WAZA_CHG_BUTTON_PX, WAZA_CHG_BUTTON_PY );

		PSTBMP_WazaChgCheckSet( wk, FALSE );
	}
}


//--------------------------------------------------------------------------------------------
/**
 * ボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	frm		ＢＧフレーム
 * @param	px		Ｘ座標
 * @param	py		Ｙ座標
 * @param	sx		Ｘサイズ
 * @param	sy		Ｙサイズ
 * @param	pal1	パレット１
 * @param	pal2	パレット２
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int ButtonAnmSet( PST_WORK * wk, u8 frm, u8 px, u8 py, u8 sx, u8 sy, u8 pal1, u8 pal2, u8 next )
{
	wk->button_px = px;
	wk->button_py = py;
	wk->button_sx = sx;
	wk->button_sy = sy;
	wk->button_pal1 = pal1;
	wk->button_pal2 = pal2;
	wk->button_frm = frm;
	wk->button_cnt = 0;
	wk->button_next = next;

	return SEQ_BUTTON_ANM;
}

//--------------------------------------------------------------------------------------------
/**
 * 「やめる」ボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int RetButtonAnmSet( PST_WORK * wk, u8 next )
{
	return ButtonAnmSet( wk, GF_BGL_FRAME2_S, 23, 20, 9, 4, 1, 0, next );
}

//--------------------------------------------------------------------------------------------
/**
 * 「わすれさせる」ボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int WazaOboeCheckButtonAnmSet( PST_WORK * wk, u8 next )
{
	return ButtonAnmSet(
			wk, GF_BGL_FRAME2_S,
			WAZA_OBOE_CHECK_BUTTON_PX+1, WAZA_OBOE_CHECK_BUTTON_PY+1,
			WAZA_OBOE_CHECK_BUTTON_SX-2, WAZA_OBOE_CHECK_BUTTON_SY-2,
			1, 0, next );
}

//--------------------------------------------------------------------------------------------
/**
 * 「いれかえ」ボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int WazaChangeButtonAnmSet( PST_WORK * wk, u8 next )
{
	return ButtonAnmSet(
			wk, GF_BGL_FRAME2_S,
			WAZA_CHG_BUTTON_PX, WAZA_CHG_BUTTON_PY+1,
			WAZA_CHG_BUTTON_SX, WAZA_CHG_BUTTON_SY,
			1, 0, next );
}

//--------------------------------------------------------------------------------------------
/**
 * ボックス用ポケモン切り替えボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int BoxPokeChangeButtonAnmSet( PST_WORK * wk, u8 mv, u8 next )
{
	if( mv == 0 ){
		return ButtonAnmSet(
				wk, GF_BGL_FRAME2_S,
				BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_UPY,
				BOX_POKECHG_BUTTON_SX, BOX_POKECHG_BUTTON_SY,
				1, 0, next );
	}
	return ButtonAnmSet(
			wk, GF_BGL_FRAME2_S,
			BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_DPY,
			BOX_POKECHG_BUTTON_SX, BOX_POKECHG_BUTTON_SY,
			1, 0, next );
}

// リボン選択終了ボタンアニメセット
#define	RIBBON_END_BUTTON_SX	( 6 )
#define	RIBBON_END_BUTTON_SY	( 4 )
#define	RIBBON_END_BUTTON_PX	( 26 )
#define	RIBBON_END_BUTTON_PY	( 20+9 )

//--------------------------------------------------------------------------------------------
/**
 * リボン選択終了ボタンアニメセット
 *
 * @param	wk		ステータス画面ワーク
 * @param	next	アニメ後に移行するシーケンス
 *
 * @return	シーケンス：SEQ_BUTTON_ANM
 */
//--------------------------------------------------------------------------------------------
static int RibbonSelEndButtonAnmSet( PST_WORK * wk, u8 next )
{
	return ButtonAnmSet(
			wk, GF_BGL_FRAME1_S,
			RIBBON_END_BUTTON_PX, RIBBON_END_BUTTON_PY,
			RIBBON_END_BUTTON_SX, RIBBON_END_BUTTON_SY,
			1, 0, next );
}


#define	BOX_POKE_ARROW_FILL_CHAR	( 1 )

//--------------------------------------------------------------------------------------------
/**
 * ボックス用ポケモン切り替え矢印表示
 *
 * @param	wk		ステータス画面ワーク
 *
 * @return	none
 */
//--------------------------------------------------------------------------------------------
static void BoxPokeChangeArrowPut( PST_WORK * wk )
{
	if( PokeSearch( wk, -1 ) != -1 ){
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_BOX_SU, BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_UPY );
	}else{
		GF_BGL_ScrFill(
			wk->bgl, GF_BGL_FRAME2_S, BOX_POKE_ARROW_FILL_CHAR,
			BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_UPY,
			BGWF_BOX_ARROW_SX, BGWF_BOX_ARROW_SY, GF_BGL_SCRWRT_PALNL );
		GF_BGL_LoadScreenV_Req( wk->bgl, GF_BGL_FRAME2_S );
	}
	if( PokeSearch( wk, 1 ) != -1 ){
		BGWINFRM_FramePut(
			wk->wfrm, PST_WFRM_BOX_SD, BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_DPY );
	}else{
		GF_BGL_ScrFill(
			wk->bgl, GF_BGL_FRAME2_S, BOX_POKE_ARROW_FILL_CHAR,
			BOX_POKECHG_BUTTON_PX, BOX_POKECHG_BUTTON_DPY,
			BGWF_BOX_ARROW_SX, BGWF_BOX_ARROW_SY, GF_BGL_SCRWRT_PALNL );
		GF_BGL_LoadScreenV_Req( wk->bgl, GF_BGL_FRAME2_S );
	}
}